Update quickstart, make it deployable
This commit is contained in:
7
examples/quickstart/Dockerfile
Normal file
7
examples/quickstart/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FROM dailyco/pipecat-base:latest
|
||||||
|
|
||||||
|
COPY ./requirements.txt requirements.txt
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
||||||
|
|
||||||
|
COPY ./bot.py bot.py
|
||||||
@@ -4,15 +4,10 @@ Run your first Pipecat bot in under 5 minutes. This example creates a voice AI b
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
### Python 3.10+
|
### Environment
|
||||||
|
|
||||||
Pipecat requires Python 3.10 or newer. Check your version:
|
- Python 3.10 or later
|
||||||
|
- [uv](https://docs.astral.sh/uv/getting-started/installation/) package manager installed
|
||||||
```bash
|
|
||||||
python --version
|
|
||||||
```
|
|
||||||
|
|
||||||
If you need to upgrade Python, we recommend using a version manager like `uv` or `pyenv`.
|
|
||||||
|
|
||||||
### AI Service API keys
|
### AI Service API keys
|
||||||
|
|
||||||
@@ -26,26 +21,21 @@ Have your API keys ready. We'll add them to your `.env` shortly.
|
|||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
1. Set up a virtual environment
|
### Set up your environment and dependencies
|
||||||
|
|
||||||
From the `examples/quickstart` directory, run:
|
From `examples/quickstart`, run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python -m venv .venv
|
uv sync --extra webrtc \
|
||||||
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
--extra daily \
|
||||||
|
--extra silero \
|
||||||
|
--extra deepgram \
|
||||||
|
--extra openai \
|
||||||
|
--extra cartesia \
|
||||||
|
--extra runner
|
||||||
```
|
```
|
||||||
|
|
||||||
> Using `uv`? Create your venv using: `uv venv && source .venv/bin/activate`.
|
### Configure environment variables
|
||||||
|
|
||||||
2. Install dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
> Using `uv`? Install requirements using: `uv pip install -r requirements.txt`.
|
|
||||||
|
|
||||||
3. Configure environment variables
|
|
||||||
|
|
||||||
Create a `.env` file:
|
Create a `.env` file:
|
||||||
|
|
||||||
@@ -55,25 +45,110 @@ cp env.example .env
|
|||||||
|
|
||||||
Then, add your API keys:
|
Then, add your API keys:
|
||||||
|
|
||||||
```
|
```ini
|
||||||
DEEPGRAM_API_KEY=your_deepgram_api_key
|
DEEPGRAM_API_KEY=your_deepgram_api_key
|
||||||
OPENAI_API_KEY=your_openai_api_key
|
OPENAI_API_KEY=your_openai_api_key
|
||||||
CARTESIA_API_KEY=your_cartesia_api_key
|
CARTESIA_API_KEY=your_cartesia_api_key
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Run the example
|
## Run your bot locally
|
||||||
|
|
||||||
Run your bot using:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python bot.py
|
uv run bot.py
|
||||||
```
|
```
|
||||||
|
|
||||||
> Using `uv`? Run your bot using: `uv run bot.py`.
|
|
||||||
|
|
||||||
**Open http://localhost:7860 in your browser** and click `Connect` to start talking to your bot.
|
**Open http://localhost:7860 in your browser** and click `Connect` to start talking to your bot.
|
||||||
|
|
||||||
> 💡 First run note: The initial startup may take ~10 seconds as Pipecat downloads required models, like the Silero VAD model.
|
> 💡 First run note: The initial startup may take ~20 seconds as Pipecat downloads required models and imports.
|
||||||
|
|
||||||
|
## Deploy to Pipecat Cloud (Optional)
|
||||||
|
|
||||||
|
Pipecat Cloud is a managed platform for hosting and scaling your Pipecat bots in production.
|
||||||
|
|
||||||
|
[Sign up](https://pipecat.daily.co/sign-up) for a Pipecat Cloud account and deploy your bot in minutes.
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
#### Install `pipecatcloud`
|
||||||
|
|
||||||
|
The `pipecatcloud` CLI manages your Pipecat deployments, secrets, and organization. Install in your virtual enviroment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv add pipecatcloud
|
||||||
|
```
|
||||||
|
|
||||||
|
> 💡 Tip: You can run the `pipecatcloud` CLI using the `pcc` alias.
|
||||||
|
|
||||||
|
#### Docker
|
||||||
|
|
||||||
|
Pipecat Cloud expects a built Docker image that includes the agent code and all dependencies. You need to:
|
||||||
|
|
||||||
|
1. Install [Docker](https://www.docker.com/) on your system.
|
||||||
|
2. Create a container registry account. We'll use [Docker Hub](https://hub.docker.com/) in this example.
|
||||||
|
|
||||||
|
### Configure pcc-deploy.toml
|
||||||
|
|
||||||
|
The `pcc-deploy.toml` file is the spec for your Pipecat Cloud deployment.
|
||||||
|
|
||||||
|
```ini
|
||||||
|
agent_name = "quickstart"
|
||||||
|
image = "your_username/quickstart:0.1"
|
||||||
|
secret_set = "quickstart-secrets"
|
||||||
|
|
||||||
|
[scaling]
|
||||||
|
min_agents = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
Details:
|
||||||
|
|
||||||
|
- `agent_name`: the name of your Pipecat Cloud agent
|
||||||
|
- `image`: your Docker Hub username and image tag (image_name:version) to run
|
||||||
|
- `secret_set`: environment variable secrets that you can use in your bot file
|
||||||
|
- `min_agents`: the number of reserve instances you'll run. We'll start with 1 to ensure you get an instant start
|
||||||
|
|
||||||
|
> 💡 Tip: [Set up `image_credentials`](https://docs.pipecat.ai/deployment/pipecat-cloud/fundamentals/secrets#image-pull-secrets) in your TOML file for authenticated image pulls
|
||||||
|
|
||||||
|
### Configure secrets
|
||||||
|
|
||||||
|
Store your secrets in Pipecat Cloud and use the environment variable keys in your bot file. To create secrets, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv run pcc secrets set quickstart-secrets --file .env
|
||||||
|
```
|
||||||
|
|
||||||
|
This command creates a new secret set called `quickstart-secrets`. This value must match the `secret_set` in your TOML file. The `--file` arg points your `.env` file. This will add all environment variables from the file to the secret set.
|
||||||
|
|
||||||
|
## Build and push your Docker image
|
||||||
|
|
||||||
|
Pipecat Cloud expects a built Docker image that includes the agent code and all dependencies. You can build, tag, and push your Docker image using the included `build.sh` shell script:
|
||||||
|
|
||||||
|
1. Login to Docker Hub:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker login
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Update the `VERSION`, `DOCKER_USERNAME`, and `AGENT_NAME` to match your TOML file.
|
||||||
|
3. Run the script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy your agent
|
||||||
|
|
||||||
|
You're ready to deploy your agent. Use the following command to deploy your agent according to the spec in your `pcc-deploy.toml` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv run pcc deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
## Connect to your agent
|
||||||
|
|
||||||
|
The Pipecat Cloud dashboard has a Sandbox which makes it easy to talk to your agent. In your [Pipecat Cloud dashboard](https://pipecat.daily.co/), select your `quickstart` agent > Sandbox.
|
||||||
|
|
||||||
|
- Accept the browser prompt for device access.
|
||||||
|
- Click `Connect` to start your agent.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,13 @@
|
|||||||
"""Pipecat Quickstart Example.
|
"""Pipecat Quickstart Example.
|
||||||
|
|
||||||
The example runs a simple voice AI bot that you can connect to using your
|
The example runs a simple voice AI bot that you can connect to using your
|
||||||
browser and speak with it.
|
browser and speak with it. You can also deploy this bot to Pipecat Cloud.
|
||||||
|
|
||||||
Required AI services:
|
Required AI services:
|
||||||
- Deepgram (Speech-to-Text)
|
- Deepgram (Speech-to-Text)
|
||||||
- OpenAI (LLM)
|
- OpenAI (LLM)
|
||||||
- Cartesia (Text-to-Speech)
|
- Cartesia (Text-to-Speech)
|
||||||
|
|
||||||
The example connects between client and server using a P2P WebRTC connection.
|
|
||||||
|
|
||||||
Run the bot using::
|
Run the bot using::
|
||||||
|
|
||||||
python bot.py
|
python bot.py
|
||||||
@@ -27,7 +25,7 @@ from dotenv import load_dotenv
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
print("🚀 Starting Pipecat bot...")
|
print("🚀 Starting Pipecat bot...")
|
||||||
print("⏳ Loading AI models (30-40 seconds first run, <2 seconds after)\n")
|
print("⏳ Loading models and imports (20 seconds first run only)\n")
|
||||||
|
|
||||||
logger.info("Loading Silero VAD model...")
|
logger.info("Loading Silero VAD model...")
|
||||||
from pipecat.audio.vad.silero import SileroVADAnalyzer
|
from pipecat.audio.vad.silero import SileroVADAnalyzer
|
||||||
@@ -40,15 +38,12 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask
|
|||||||
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
||||||
from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor
|
from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor
|
||||||
from pipecat.runner.types import RunnerArguments
|
from pipecat.runner.types import RunnerArguments
|
||||||
|
from pipecat.runner.utils import create_transport
|
||||||
from pipecat.services.cartesia.tts import CartesiaTTSService
|
from pipecat.services.cartesia.tts import CartesiaTTSService
|
||||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||||
from pipecat.services.openai.llm import OpenAILLMService
|
from pipecat.services.openai.llm import OpenAILLMService
|
||||||
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
||||||
|
from pipecat.transports.services.daily import DailyParams
|
||||||
logger.info("✅ Pipeline components loaded")
|
|
||||||
|
|
||||||
logger.info("Loading WebRTC transport...")
|
|
||||||
from pipecat.transports.network.small_webrtc import SmallWebRTCTransport
|
|
||||||
|
|
||||||
logger.info("✅ All components loaded successfully!")
|
logger.info("✅ All components loaded successfully!")
|
||||||
|
|
||||||
@@ -121,14 +116,20 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def bot(runner_args: RunnerArguments):
|
async def bot(runner_args: RunnerArguments):
|
||||||
"""Main bot entry point for the bot starter."""
|
"""Main bot entry point for the bot starter."""
|
||||||
|
|
||||||
transport = SmallWebRTCTransport(
|
transport_params = {
|
||||||
params=TransportParams(
|
"daily": lambda: DailyParams(
|
||||||
audio_in_enabled=True,
|
audio_in_enabled=True,
|
||||||
audio_out_enabled=True,
|
audio_out_enabled=True,
|
||||||
vad_analyzer=SileroVADAnalyzer(),
|
vad_analyzer=SileroVADAnalyzer(),
|
||||||
),
|
),
|
||||||
webrtc_connection=runner_args.webrtc_connection,
|
"webrtc": lambda: TransportParams(
|
||||||
)
|
audio_in_enabled=True,
|
||||||
|
audio_out_enabled=True,
|
||||||
|
vad_analyzer=SileroVADAnalyzer(),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
transport = await create_transport(runner_args, transport_params)
|
||||||
|
|
||||||
await run_bot(transport, runner_args)
|
await run_bot(transport, runner_args)
|
||||||
|
|
||||||
|
|||||||
19
examples/quickstart/build.sh
Executable file
19
examples/quickstart/build.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
VERSION="0.1"
|
||||||
|
DOCKER_USERNAME="your_username"
|
||||||
|
AGENT_NAME="quickstart"
|
||||||
|
|
||||||
|
# Build the Docker image with the correct context
|
||||||
|
echo "Building Docker image..."
|
||||||
|
docker build --platform=linux/arm64 -t "$DOCKER_USERNAME/$AGENT_NAME:$VERSION" -t "$DOCKER_USERNAME/$AGENT_NAME:latest" .
|
||||||
|
|
||||||
|
# Push the Docker images
|
||||||
|
echo "Pushing Docker image $DOCKER_USERNAME/$AGENT_NAME:$VERSION..."
|
||||||
|
docker push "$DOCKER_USERNAME/$AGENT_NAME:$VERSION"
|
||||||
|
|
||||||
|
echo "Pushing Docker image $DOCKER_USERNAME/$AGENT_NAME:latest..."
|
||||||
|
docker push "$DOCKER_USERNAME/$AGENT_NAME:latest"
|
||||||
|
|
||||||
|
echo "Successfully built and pushed $DOCKER_USERNAME/$AGENT_NAME:$VERSION and $DOCKER_USERNAME/$AGENT_NAME:latest"
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
DEEPGRAM_API_KEY=your_deepgram_api_key
|
DEEPGRAM_API_KEY=your_deepgram_api_key
|
||||||
OPENAI_API_KEY=your_openai_api_key
|
OPENAI_API_KEY=your_openai_api_key
|
||||||
CARTESIA_API_KEY=your_cartesia_api_key
|
CARTESIA_API_KEY=your_cartesia_api_key
|
||||||
|
|
||||||
|
# Optional: Connect via Daily WebRTC locally
|
||||||
|
DAILY_API_KEY=your_daily_api_key
|
||||||
6
examples/quickstart/pcc-deploy.toml
Normal file
6
examples/quickstart/pcc-deploy.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
agent_name = "quickstart"
|
||||||
|
image = "your_username/quickstart:0.1"
|
||||||
|
secret_set = "quickstart-secrets"
|
||||||
|
|
||||||
|
[scaling]
|
||||||
|
min_agents = 1
|
||||||
@@ -1 +1,2 @@
|
|||||||
pipecat-ai[webrtc,silero,deepgram,openai,cartesia,runner]>=0.0.77
|
pipecat-ai[webrtc,websocket,daily,silero,deepgram,openai,cartesia,runner]>=0.0.77
|
||||||
|
pipecatcloud>=0.2.1
|
||||||
Reference in New Issue
Block a user