Update the simple-chatbot demo to have JS and React clients

This commit is contained in:
Mark Backman
2024-12-04 21:13:14 -05:00
parent c395d1a234
commit 1d11419691
2634 changed files with 179150 additions and 328 deletions

View File

@@ -1,37 +1,78 @@
# Simple Chatbot
# Simple Chatbot Implementation
<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 app connects you to a chatbot powered by GPT-4, complete with animations generated by Stable Video Diffusion.
## Three Ways to Connect
See a video of it in action: https://x.com/kwindla/status/1778628911817183509
1. **Daily Prebuilt** (Simplest)
And a quick video walkthrough of the code: https://www.loom.com/share/13df1967161f4d24ade054e7f8753416
- Direct connection through a Daily Prebuilt room
- For demo purposes only; handy for quick testing
The first time, things might take extra time to get started since VAD (Voice Activity Detection) model needs to be downloaded.
2. **JavaScript**
## Get started
- Basic implementation using RTVI JavaScript SDK
- No framework dependencies
- Good for learning the fundamentals
```python
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
3. **React**
- Basic impelmentation using RTVI React SDK
- Demonstrates the basic client principles with RTVI React
cp env.example .env # and add your credentials
## Quick Start
### First, start the bot server:
1. Navigate to the server directory:
```bash
cd server
```
2. Create and activate a virtual environment:
```bash
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install requirements:
```bash
pip install -r requirements.txt
```
4. Copy env.example to .env and add your credentials
5. Start the server:
```bash
python server.py
```
### Next, connect using your preferred client app:
- [Daily Prebuilt](examples/prebuilt/README.md)
- [Vanilla JavaScript Guide](examples/javascript/README.md)
- [React Guide](examples/react/README.md)
## Important Note
The bot server must be running for any of the client implementations to work. Start the server first before trying any of the client apps.
## Requirements
- Python 3.10+
- Node.js 16+ (for JavaScript and React implementations)
- Daily API key
- OpenAI API key
- Cartesia API key
- Modern web browser with WebRTC support
## Project Structure
```
## Run the server
```bash
python server.py
```
Then, visit `http://localhost:7860/` in your browser to start a chatbot session.
## Build and test the Docker image
```
docker build -t chatbot .
docker run --env-file .env -p 7860:7860 chatbot
simple-chatbot-full-stack/
├── server/ # Bot server implementation
│ ├── bot.py # Bot logic and media handling
│ ├── 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
```