Skip to content

Commit

Permalink
Merge pull request #831 from pipecat-ai/mb/gemini-simple-chatbot
Browse files Browse the repository at this point in the history
Gemini updates to the simple-chatbot demo
  • Loading branch information
markbackman authored Dec 11, 2024
2 parents 62ec2f5 + 2846d6f commit 3341c4f
Show file tree
Hide file tree
Showing 10 changed files with 387 additions and 54 deletions.
53 changes: 35 additions & 18 deletions examples/simple-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

<img src="image.png" width="420px">

This repository demonstrates a simple AI chatbot with real-time audio/video interaction, implemented in three different ways. The bot server remains the same, but you can connect to it using three different client approaches.
This repository demonstrates a simple AI chatbot with real-time audio/video interaction, implemented in three different ways. The bot server supports multiple AI backends, and you can connect to it using three different client approaches.

## Two Bot Options

1. **OpenAI Bot** (Default)

- Uses gpt-4o for conversation
- Requires OpenAI API key

2. **Gemini Bot**
- Uses Google's Gemini Multimodal Live model
- Requires Gemini API key

## Three Ways to Connect

Expand All @@ -13,13 +24,13 @@ This repository demonstrates a simple AI chatbot with real-time audio/video inte

2. **JavaScript**

- Basic implementation using RTVI JavaScript SDK
- Basic implementation using [Pipecat JavaScript SDK](https://docs.pipecat.ai/client/reference/js/introduction)
- No framework dependencies
- Good for learning the fundamentals

3. **React**
- Basic impelmentation using RTVI React SDK
- Demonstrates the basic client principles with RTVI React
- Basic impelmentation using [Pipecat React SDK](https://docs.pipecat.ai/client/reference/react/introduction)
- Demonstrates the basic client principles with Pipecat React

## Quick Start

Expand All @@ -38,8 +49,12 @@ This repository demonstrates a simple AI chatbot with real-time audio/video inte
```bash
pip install -r requirements.txt
```
4. Copy env.example to .env and add your credentials

4. Copy env.example to .env and configure:
- Add your API keys
- Choose your bot implementation:
```ini
BOT_IMPLEMENTATION= # Options: 'openai' (default) or 'gemini'
```
5. Start the server:
```bash
python server.py
Expand All @@ -48,7 +63,7 @@ This repository demonstrates a simple AI chatbot with real-time audio/video inte
### Next, connect using your preferred client app:

- [Daily Prebuilt](examples/prebuilt/README.md)
- [Vanilla JavaScript Guide](examples/javascript/README.md)
- [JavaScript Guide](examples/javascript/README.md)
- [React Guide](examples/react/README.md)

## Important Note
Expand All @@ -60,21 +75,23 @@ The bot server must be running for any of the client implementations to work. St
- Python 3.10+
- Node.js 16+ (for JavaScript and React implementations)
- Daily API key
- OpenAI API key
- Cartesia API key
- OpenAI API key (for OpenAI bot)
- Gemini API key (for Gemini bot)
- ElevenLabs API key
- Modern web browser with WebRTC support

## Project Structure

```
simple-chatbot-full-stack/
├── server/ # Bot server implementation
│ ├── bot.py # Bot logic and media handling
│ ├── runner.py # Server runner utilities
│ ├── server.py # FastAPI server
simple-chatbot/
├── server/ # Bot server implementation
│ ├── bot-openai.py # OpenAI bot implementation
│ ├── bot-gemini.py # Gemini bot implementation
│ ├── runner.py # Server runner utilities
│ ├── server.py # FastAPI server
│ └── requirements.txt
└── examples/ # Client implementations
├── prebuilt/ # Daily Prebuilt connection
├── javascript/ # JavaScript RTVI client
└── react/ # React RTVI client
└── examples/ # Client implementations
├── prebuilt/ # Daily Prebuilt connection
├── javascript/ # Pipecat JavaScript client
└── react/ # Pipecat React client
```
4 changes: 2 additions & 2 deletions examples/simple-chatbot/examples/javascript/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# JavaScript Implementation

Basic implementation using the RTVI JavaScript SDK.
Basic implementation using the [Pipecat JavaScript SDK](https://docs.pipecat.ai/client/reference/js/introduction).

## Setup

1. Run the bot server; see [README](../../README).
1. Run the bot server. See the [server README](../../README).

2. Navigate to the `examples/javascript` directory:

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-chatbot/examples/react/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# React Implementation

Basic implementation using the RTVI React SDK.
Basic implementation using the [Pipecat React SDK](https://docs.pipecat.ai/client/reference/react/introduction).

## Setup

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-chatbot/examples/react/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RTVI React Client</title>
<title>Pipecat React Client</title>
</head>

<body>
Expand Down
31 changes: 27 additions & 4 deletions examples/simple-chatbot/server/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
# Simple Chatbot Server

A FastAPI server that manages bot instances and provides endpoints for both Daily Prebuilt and RTVI client connections.
A FastAPI server that manages bot instances and provides endpoints for both Daily Prebuilt and Pipecat client connections.

## Endpoints

- `GET /` - Direct browser access, redirects to a Daily Prebuilt room
- `POST /connect` - RTVI client connection endpoint
- `POST /connect` - Pipecat client connection endpoint
- `GET /status/{pid}` - Get status of a specific bot process

## Environment Variables

Copy `env.example` to `.env` and configure:

```ini
# Required API Keys
DAILY_API_KEY= # Your Daily API key
OPENAI_API_KEY= # Your OpenAI API key (required for OpenAI bot)
GEMINI_API_KEY= # Your Gemini API key (required for Gemini bot)
ELEVENLABS_API_KEY= # Your ElevenLabs API key

# Bot Selection
BOT_IMPLEMENTATION= # Options: 'openai' or 'gemini'

# Optional Configuration
DAILY_API_URL= # Optional: Daily API URL (defaults to https://api.daily.co/v1)
OPENAI_API_KEY= # Your OpenAI API key
CARTESIA_API_KEY= # Your Cartesia API key
DAILY_SAMPLE_ROOM_URL= # Optional: Fixed room URL for development
HOST= # Optional: Host address (defaults to 0.0.0.0)
FAST_API_PORT= # Optional: Port number (defaults to 7860)
```

## Available Bots

The server supports two bot implementations:

1. **OpenAI Bot** (Default)

- Uses GPT-4 for conversation
- Requires OPENAI_API_KEY

2. **Gemini Bot**
- Uses Google's Gemini model
- Requires GEMINI_API_KEY

Select your preferred bot by setting `BOT_IMPLEMENTATION` in your `.env` file.

## Running the Server

Set up and activate your virtual environment:
Expand Down
Loading

0 comments on commit 3341c4f

Please sign in to comment.