Merge pull request #1613 from pipecat-ai/mb/improve-storybot-readme

demo: Restructure storytelling-chatbot directory, update README steps…
This commit is contained in:
Mark Backman
2025-05-02 16:39:59 -04:00
committed by GitHub
53 changed files with 69 additions and 41 deletions

View File

@@ -1,2 +0,0 @@
frontend/node_modules
frontend/out

View File

@@ -1,4 +1,4 @@
[![Try](https://img.shields.io/badge/try_it-here-blue)](https://storytelling-chatbot.fly.dev)
[![Try](https://img.shields.io/badge/try_it-here-blue)](https://gemini-storybot.vercel.app/)
# Storytelling Chatbot
@@ -9,7 +9,6 @@ It periodically prompts the user for input for a 'choose your own adventure' sty
We use Gemini 2.0 for creating the story and image prompts, and we add visual elements to the story by generating images using Google's Imagen.
---
### It uses the following AI services:
@@ -20,7 +19,7 @@ Transcribes inbound participant voice media to text.
**Google Gemini 2.0 - LLM**
Our creative writer LLM. You can see the context used to prompt it [here](src/prompts.py)
Our creative writer LLM. You can see the context used to prompt it [here](server/prompts.py)
**ElevenLabs - Text-to-Speech**
@@ -34,47 +33,76 @@ Adds pictures to our story. Prompting is quite key for style consistency, so we
## Setup
**Install requirements**
### Client
```shell
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
1. Navigate to the client directory:
**Create environment file and set variables:**
```shell
cd client
```
```shell
mv env.example .env
```
2. Install dependencies:
When deploying to production, to ensure only this app can spawn a new bot, set your `ENV` to `production`
```shell
npm install
```
**Build the frontend:**
3. Build the client:
This project uses a custom frontend, which needs to built. Note: this is done automatically as part of the Docker deployment.
```shell
npm run build
```
```shell
cd frontend/
npm install
npm run build
```
### Server
The build UI files can be found in `frontend/out`
1. Navigate to the server directory
## Running it locally
```shell
cd ../server
```
Start the API / bot manager:
2. Set up your virtual environment and install requirements
`python src/bot_runner.py --host localhost`
```shell
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
If you'd like to run a custom domain or port:
3. Create environment file and set variables
`python src/bot_runner.py --host somehost --p someport`
```shell
mv env.example .env
```
➡️ Open the host URL in your browser `http://localhost:7860`
You'll need API keys for:
If you've run previous versions of the demo, make sure to set `ENV=dev`, and remove the `RUN_AS_VM` line from the .env file.
- DAILY_API_KEY
- ELEVENLABS_API_KEY
- ELEVENLABS_VOICE_ID
- GOOGLE_API_KEY
4. (Optional) Deployment:
When deploying to production, to ensure only this app can spawn new bot processes, set your `ENV` to `production`
## Run it locally
1. Navigate back to the demo's root directory:
```shell
cd ..
```
2. Run the application:
```shell
python server/bot_runner.py --host localhost
```
You can run with a custom domain or port using: `python server/bot_runner.py --host somehost --p someport`
3. ➡️ Open the host URL in your browser: http://localhost:7860
---

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

@@ -1,11 +1,11 @@
{
"name": "frontend",
"name": "client",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "frontend",
"name": "client",
"version": "0.1.0",
"dependencies": {
"@daily-co/daily-js": "^0.62.0",

View File

@@ -1,5 +1,5 @@
{
"name": "frontend",
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 788 KiB

After

Width:  |  Height:  |  Size: 788 KiB

View File

@@ -0,0 +1,2 @@
client/node_modules
client/out

View File

@@ -44,11 +44,11 @@ COPY ./requirements.txt requirements.txt
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
# Copy everything else
COPY --chown=user ./src/ src/
COPY --chown=user ./server/ server/
# Copy frontend app and build
COPY --chown=user ./frontend/ frontend/
RUN cd frontend && npm install && npm run build
# Copy client app and build
COPY --chown=user ./client/ client/
RUN cd client && npm install && npm run build
# Start the FastAPI server
CMD python3 src/bot_runner.py --port ${FAST_API_PORT}
CMD python3 server/bot_runner.py --port ${FAST_API_PORT}

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@@ -57,7 +57,7 @@ app.add_middleware(
)
# Mount the static directory
STATIC_DIR = "frontend/out"
STATIC_DIR = "client/out"
# ------------ Fast API Routes ------------ #
@@ -175,7 +175,7 @@ async def virtualize_bot(room_url: str, token: str):
image = data[0]["config"]["image"]
# Machine configuration
cmd = f"python src/bot.py -u {room_url} -t {token}"
cmd = f"python server/bot.py -u {room_url} -t {token}"
cmd = cmd.split()
worker_props = {
"config": {