Rename services/ to voice/ and function-calling/, flatten to top level
Replace the nested services/speech/ and services/function-calling/ with top-level voice/ and function-calling/ directories. Update eval script paths and README to match.
This commit is contained in:
@@ -61,12 +61,13 @@ uv run getting-started/06-voice-agent.py -t twilio -x NGROK_HOST_NAME
|
||||
|
||||
Progressive introduction to Pipecat, from minimal TTS to a full voice agent with function calling.
|
||||
|
||||
### [`services/`](./services/)
|
||||
### [`voice/`](./voice/)
|
||||
|
||||
Service provider integration examples, organized into subfolders:
|
||||
Full STT + LLM + TTS voice agent pipelines showcasing different speech service providers (Deepgram, ElevenLabs, Cartesia, etc.)
|
||||
|
||||
- **[`speech/`](./services/speech/)** — Full STT + LLM + TTS pipelines showcasing different speech service providers (Deepgram, ElevenLabs, Cartesia, etc.)
|
||||
- **[`function-calling/`](./services/function-calling/)** — Function calling with different LLM providers (OpenAI, Anthropic, Google, etc.)
|
||||
### [`function-calling/`](./function-calling/)
|
||||
|
||||
Function calling with different LLM providers (OpenAI, Anthropic, Google, etc.)
|
||||
|
||||
### [`transcription/`](./transcription/)
|
||||
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2024-2026, Daily
|
||||
#
|
||||
# SPDX-License-Identifier: BSD 2-Clause License
|
||||
#
|
||||
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from loguru import logger
|
||||
|
||||
from pipecat.adapters.schemas.function_schema import FunctionSchema
|
||||
from pipecat.adapters.schemas.tools_schema import ToolsSchema
|
||||
from pipecat.audio.vad.silero import SileroVADAnalyzer
|
||||
from pipecat.frames.frames import LLMRunFrame, TTSSpeakFrame
|
||||
from pipecat.pipeline.pipeline import Pipeline
|
||||
from pipecat.pipeline.runner import PipelineRunner
|
||||
from pipecat.pipeline.task import PipelineParams, PipelineTask
|
||||
from pipecat.processors.aggregators.llm_context import LLMContext
|
||||
from pipecat.processors.aggregators.llm_response_universal import (
|
||||
LLMContextAggregatorPair,
|
||||
LLMUserAggregatorParams,
|
||||
)
|
||||
from pipecat.runner.types import RunnerArguments
|
||||
from pipecat.runner.utils import create_transport
|
||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||
from pipecat.services.elevenlabs.tts import ElevenLabsTTSService
|
||||
from pipecat.services.google.vertex.llm import GoogleVertexLLMService
|
||||
from pipecat.services.llm_service import FunctionCallParams
|
||||
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
||||
from pipecat.transports.daily.transport import DailyParams
|
||||
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
||||
|
||||
load_dotenv(override=True)
|
||||
|
||||
|
||||
async def fetch_weather_from_api(params: FunctionCallParams):
|
||||
await params.result_callback({"conditions": "nice", "temperature": "75"})
|
||||
|
||||
|
||||
# We use lambdas to defer transport parameter creation until the transport
|
||||
# type is selected at runtime.
|
||||
transport_params = {
|
||||
"daily": lambda: DailyParams(
|
||||
audio_in_enabled=True,
|
||||
audio_out_enabled=True,
|
||||
),
|
||||
"twilio": lambda: FastAPIWebsocketParams(
|
||||
audio_in_enabled=True,
|
||||
audio_out_enabled=True,
|
||||
),
|
||||
"webrtc": lambda: TransportParams(
|
||||
audio_in_enabled=True,
|
||||
audio_out_enabled=True,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
||||
logger.info(f"Starting bot")
|
||||
|
||||
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
||||
|
||||
tts = ElevenLabsTTSService(
|
||||
api_key=os.getenv("ELEVENLABS_API_KEY", ""),
|
||||
settings=ElevenLabsTTSService.Settings(
|
||||
voice=os.getenv("ELEVENLABS_VOICE_ID", ""),
|
||||
),
|
||||
)
|
||||
|
||||
llm = GoogleVertexLLMService(
|
||||
credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"),
|
||||
project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"),
|
||||
location=os.getenv("GOOGLE_CLOUD_LOCATION"),
|
||||
settings=GoogleVertexLLMService.Settings(
|
||||
system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.",
|
||||
),
|
||||
)
|
||||
# You can aslo register a function_name of None to get all functions
|
||||
# sent to the same callback with an additional function_name parameter.
|
||||
llm.register_function("get_current_weather", fetch_weather_from_api)
|
||||
|
||||
@llm.event_handler("on_function_calls_started")
|
||||
async def on_function_calls_started(service, function_calls):
|
||||
await tts.queue_frame(TTSSpeakFrame("Let me check on that."))
|
||||
|
||||
weather_function = FunctionSchema(
|
||||
name="get_current_weather",
|
||||
description="Get the current weather",
|
||||
properties={
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "The city and state, e.g. San Francisco, CA",
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": ["celsius", "fahrenheit"],
|
||||
"description": "The temperature unit to use. Infer this from the user's location.",
|
||||
},
|
||||
},
|
||||
required=["location", "format"],
|
||||
)
|
||||
tools = ToolsSchema(standard_tools=[weather_function])
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "developer",
|
||||
"content": "Start a conversation with 'Hey there' to get the current weather.",
|
||||
},
|
||||
]
|
||||
|
||||
context = LLMContext(messages, tools)
|
||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||
context,
|
||||
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
||||
)
|
||||
|
||||
pipeline = Pipeline(
|
||||
[
|
||||
transport.input(),
|
||||
stt,
|
||||
user_aggregator,
|
||||
llm,
|
||||
tts,
|
||||
transport.output(),
|
||||
assistant_aggregator,
|
||||
]
|
||||
)
|
||||
|
||||
task = PipelineTask(
|
||||
pipeline,
|
||||
params=PipelineParams(
|
||||
enable_metrics=True,
|
||||
enable_usage_metrics=True,
|
||||
),
|
||||
idle_timeout_secs=runner_args.pipeline_idle_timeout_secs,
|
||||
)
|
||||
|
||||
@transport.event_handler("on_client_connected")
|
||||
async def on_client_connected(transport, client):
|
||||
logger.info(f"Client connected")
|
||||
# Kick off the conversation.
|
||||
await task.queue_frames([LLMRunFrame()])
|
||||
|
||||
@transport.event_handler("on_client_disconnected")
|
||||
async def on_client_disconnected(transport, client):
|
||||
logger.info(f"Client disconnected")
|
||||
await task.cancel()
|
||||
|
||||
runner = PipelineRunner(handle_sigint=runner_args.handle_sigint)
|
||||
|
||||
await runner.run(task)
|
||||
|
||||
|
||||
async def bot(runner_args: RunnerArguments):
|
||||
"""Main bot entry point compatible with Pipecat Cloud."""
|
||||
transport = await create_transport(runner_args, transport_params)
|
||||
await run_bot(transport, runner_args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from pipecat.runner.run import main
|
||||
|
||||
main()
|
||||
@@ -96,61 +96,61 @@ EVAL_COMPLETE_TURN = EvalConfig(
|
||||
)
|
||||
|
||||
|
||||
TESTS_SPEECH = [
|
||||
("services/speech/cartesia.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/cartesia-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/speechmatics.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/speechmatics-vad.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/langchain.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/deepgram.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/deepgram-flux.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/deepgram-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/elevenlabs.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/elevenlabs-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/xai.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/azure.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/azure-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/openai.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/openai-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/gladia.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/gladia-vad.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/lmnt.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/groq.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/aws.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/aws-strands.py", EVAL_WEATHER),
|
||||
("services/speech/google-gemini-tts.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/google.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/google-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/assemblyai.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/krisp-viva.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/rime.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/rime-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/nvidia.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/google-audio-in.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/fish.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/neuphonic.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/neuphonic-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/fal.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/minimax.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/sarvam.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/sarvam-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/soniox.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/inworld.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/inworld-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/asyncai.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/asyncai-http.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/aicoustics.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/hume.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/gradium.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/camb.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/piper.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/kokoro.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/resemble.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/smallest.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/openai-responses.py", EVAL_SIMPLE_MATH),
|
||||
("services/speech/openai-responses-http.py", EVAL_SIMPLE_MATH),
|
||||
TESTS_VOICE = [
|
||||
("voice/cartesia.py", EVAL_SIMPLE_MATH),
|
||||
("voice/cartesia-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/speechmatics.py", EVAL_SIMPLE_MATH),
|
||||
("voice/speechmatics-vad.py", EVAL_SIMPLE_MATH),
|
||||
("voice/langchain.py", EVAL_SIMPLE_MATH),
|
||||
("voice/deepgram.py", EVAL_SIMPLE_MATH),
|
||||
("voice/deepgram-flux.py", EVAL_SIMPLE_MATH),
|
||||
("voice/deepgram-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/elevenlabs.py", EVAL_SIMPLE_MATH),
|
||||
("voice/elevenlabs-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/xai.py", EVAL_SIMPLE_MATH),
|
||||
("voice/azure.py", EVAL_SIMPLE_MATH),
|
||||
("voice/azure-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/openai.py", EVAL_SIMPLE_MATH),
|
||||
("voice/openai-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/gladia.py", EVAL_SIMPLE_MATH),
|
||||
("voice/gladia-vad.py", EVAL_SIMPLE_MATH),
|
||||
("voice/lmnt.py", EVAL_SIMPLE_MATH),
|
||||
("voice/groq.py", EVAL_SIMPLE_MATH),
|
||||
("voice/aws.py", EVAL_SIMPLE_MATH),
|
||||
("voice/aws-strands.py", EVAL_WEATHER),
|
||||
("voice/google-gemini-tts.py", EVAL_SIMPLE_MATH),
|
||||
("voice/google.py", EVAL_SIMPLE_MATH),
|
||||
("voice/google-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/assemblyai.py", EVAL_SIMPLE_MATH),
|
||||
("voice/krisp-viva.py", EVAL_SIMPLE_MATH),
|
||||
("voice/rime.py", EVAL_SIMPLE_MATH),
|
||||
("voice/rime-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/nvidia.py", EVAL_SIMPLE_MATH),
|
||||
("voice/google-audio-in.py", EVAL_SIMPLE_MATH),
|
||||
("voice/fish.py", EVAL_SIMPLE_MATH),
|
||||
("voice/neuphonic.py", EVAL_SIMPLE_MATH),
|
||||
("voice/neuphonic-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/fal.py", EVAL_SIMPLE_MATH),
|
||||
("voice/minimax.py", EVAL_SIMPLE_MATH),
|
||||
("voice/sarvam.py", EVAL_SIMPLE_MATH),
|
||||
("voice/sarvam-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/soniox.py", EVAL_SIMPLE_MATH),
|
||||
("voice/inworld.py", EVAL_SIMPLE_MATH),
|
||||
("voice/inworld-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/asyncai.py", EVAL_SIMPLE_MATH),
|
||||
("voice/asyncai-http.py", EVAL_SIMPLE_MATH),
|
||||
("voice/aicoustics.py", EVAL_SIMPLE_MATH),
|
||||
("voice/hume.py", EVAL_SIMPLE_MATH),
|
||||
("voice/gradium.py", EVAL_SIMPLE_MATH),
|
||||
("voice/camb.py", EVAL_SIMPLE_MATH),
|
||||
("voice/piper.py", EVAL_SIMPLE_MATH),
|
||||
("voice/kokoro.py", EVAL_SIMPLE_MATH),
|
||||
("voice/resemble.py", EVAL_SIMPLE_MATH),
|
||||
("voice/smallest.py", EVAL_SIMPLE_MATH),
|
||||
("voice/openai-responses.py", EVAL_SIMPLE_MATH),
|
||||
("voice/openai-responses-http.py", EVAL_SIMPLE_MATH),
|
||||
# Needs a local XTTS docker instance running.
|
||||
# ("services/speech/xtts.py", EVAL_SIMPLE_MATH),
|
||||
# ("voice/xtts.py", EVAL_SIMPLE_MATH),
|
||||
]
|
||||
|
||||
TESTS_VISION = [
|
||||
@@ -169,44 +169,44 @@ TESTS_VISION = [
|
||||
TESTS_FUNCTION_CALLING = [
|
||||
("getting-started/07-function-calling.py", EVAL_WEATHER),
|
||||
("getting-started/07-function-calling.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("services/function-calling/openai-responses.py", EVAL_WEATHER),
|
||||
("services/function-calling/openai-responses.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("services/function-calling/openai-responses-http.py", EVAL_WEATHER),
|
||||
("services/function-calling/openai-responses-http.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("services/function-calling/anthropic.py", EVAL_WEATHER),
|
||||
("services/function-calling/anthropic.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("services/function-calling/openai.py", EVAL_WEATHER),
|
||||
("services/function-calling/google.py", EVAL_WEATHER),
|
||||
("services/function-calling/google.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("services/function-calling/groq.py", EVAL_WEATHER),
|
||||
("services/function-calling/grok.py", EVAL_WEATHER),
|
||||
("services/function-calling/azure.py", EVAL_WEATHER),
|
||||
("services/function-calling/fireworks.py", EVAL_WEATHER),
|
||||
("services/function-calling/nvidia.py", EVAL_WEATHER),
|
||||
("services/function-calling/cerebras.py", EVAL_WEATHER),
|
||||
("services/function-calling/openrouter.py", EVAL_WEATHER),
|
||||
("services/function-calling/perplexity.py", EVAL_WEATHER),
|
||||
("services/function-calling/google-vertex.py", EVAL_WEATHER),
|
||||
("services/function-calling/qwen.py", EVAL_WEATHER),
|
||||
("services/function-calling/aws.py", EVAL_WEATHER),
|
||||
("services/function-calling/sambanova.py", EVAL_WEATHER),
|
||||
("services/function-calling/aws.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("services/function-calling/nebius.py", EVAL_WEATHER),
|
||||
("services/function-calling/mistral.py", EVAL_WEATHER),
|
||||
("services/function-calling/sarvam.py", EVAL_WEATHER),
|
||||
("services/function-calling/novita.py", EVAL_WEATHER),
|
||||
("function-calling/openai-responses.py", EVAL_WEATHER),
|
||||
("function-calling/openai-responses.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("function-calling/openai-responses-http.py", EVAL_WEATHER),
|
||||
("function-calling/openai-responses-http.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("function-calling/anthropic.py", EVAL_WEATHER),
|
||||
("function-calling/anthropic.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("function-calling/openai.py", EVAL_WEATHER),
|
||||
("function-calling/google.py", EVAL_WEATHER),
|
||||
("function-calling/google.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("function-calling/groq.py", EVAL_WEATHER),
|
||||
("function-calling/grok.py", EVAL_WEATHER),
|
||||
("function-calling/azure.py", EVAL_WEATHER),
|
||||
("function-calling/fireworks.py", EVAL_WEATHER),
|
||||
("function-calling/nvidia.py", EVAL_WEATHER),
|
||||
("function-calling/cerebras.py", EVAL_WEATHER),
|
||||
("function-calling/openrouter.py", EVAL_WEATHER),
|
||||
("function-calling/perplexity.py", EVAL_WEATHER),
|
||||
("function-calling/google-vertex.py", EVAL_WEATHER),
|
||||
("function-calling/qwen.py", EVAL_WEATHER),
|
||||
("function-calling/aws.py", EVAL_WEATHER),
|
||||
("function-calling/sambanova.py", EVAL_WEATHER),
|
||||
("function-calling/aws.py", EVAL_WEATHER_AND_RESTAURANT),
|
||||
("function-calling/nebius.py", EVAL_WEATHER),
|
||||
("function-calling/mistral.py", EVAL_WEATHER),
|
||||
("function-calling/sarvam.py", EVAL_WEATHER),
|
||||
("function-calling/novita.py", EVAL_WEATHER),
|
||||
# Video
|
||||
("services/function-calling/anthropic-video.py", EVAL_VISION_CAMERA),
|
||||
("services/function-calling/aws-video.py", EVAL_VISION_CAMERA),
|
||||
("services/function-calling/google-video.py", EVAL_VISION_CAMERA),
|
||||
("services/function-calling/moondream-video.py", EVAL_VISION_CAMERA),
|
||||
("services/function-calling/openai-video.py", EVAL_VISION_CAMERA),
|
||||
("services/function-calling/openai-responses-video.py", EVAL_VISION_CAMERA),
|
||||
("services/function-calling/openai-responses-video-http.py", EVAL_VISION_CAMERA),
|
||||
("function-calling/anthropic-video.py", EVAL_VISION_CAMERA),
|
||||
("function-calling/aws-video.py", EVAL_VISION_CAMERA),
|
||||
("function-calling/google-video.py", EVAL_VISION_CAMERA),
|
||||
("function-calling/moondream-video.py", EVAL_VISION_CAMERA),
|
||||
("function-calling/openai-video.py", EVAL_VISION_CAMERA),
|
||||
("function-calling/openai-responses-video.py", EVAL_VISION_CAMERA),
|
||||
("function-calling/openai-responses-video-http.py", EVAL_VISION_CAMERA),
|
||||
# Currently not working.
|
||||
# ("services/function-calling/together.py", EVAL_WEATHER),
|
||||
# ("services/function-calling/deepseek.py", EVAL_WEATHER),
|
||||
# ("services/function-calling/gemini-openai-format.py", EVAL_WEATHER),
|
||||
# ("function-calling/together.py", EVAL_WEATHER),
|
||||
# ("function-calling/deepseek.py", EVAL_WEATHER),
|
||||
# ("function-calling/gemini-openai-format.py", EVAL_WEATHER),
|
||||
]
|
||||
|
||||
TESTS_FEATURES = [
|
||||
@@ -257,7 +257,7 @@ TESTS_THINKING_AND_MCP = [
|
||||
]
|
||||
|
||||
TESTS = [
|
||||
*TESTS_SPEECH,
|
||||
*TESTS_VOICE,
|
||||
*TESTS_VISION,
|
||||
*TESTS_FUNCTION_CALLING,
|
||||
*TESTS_FEATURES,
|
||||
|
||||
Reference in New Issue
Block a user