Merge pull request #1613 from pipecat-ai/mb/improve-storybot-readme
demo: Restructure storytelling-chatbot directory, update README steps…
@@ -1,2 +0,0 @@
|
|||||||
frontend/node_modules
|
|
||||||
frontend/out
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[](https://storytelling-chatbot.fly.dev)
|
[](https://gemini-storybot.vercel.app/)
|
||||||
|
|
||||||
# Storytelling Chatbot
|
# 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.
|
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:
|
### It uses the following AI services:
|
||||||
@@ -20,7 +19,7 @@ Transcribes inbound participant voice media to text.
|
|||||||
|
|
||||||
**Google Gemini 2.0 - LLM**
|
**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**
|
**ElevenLabs - Text-to-Speech**
|
||||||
|
|
||||||
@@ -34,47 +33,76 @@ Adds pictures to our story. Prompting is quite key for style consistency, so we
|
|||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
**Install requirements**
|
### Client
|
||||||
|
|
||||||
```shell
|
1. Navigate to the client directory:
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
**Create environment file and set variables:**
|
```shell
|
||||||
|
cd client
|
||||||
|
```
|
||||||
|
|
||||||
```shell
|
2. Install dependencies:
|
||||||
mv env.example .env
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
### Server
|
||||||
cd frontend/
|
|
||||||
npm install
|
|
||||||
npm run build
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "client",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "frontend",
|
"name": "client",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@daily-co/daily-js": "^0.62.0",
|
"@daily-co/daily-js": "^0.62.0",
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "client",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 788 KiB After Width: | Height: | Size: 788 KiB |
2
examples/storytelling-chatbot/server/.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
client/node_modules
|
||||||
|
client/out
|
||||||
@@ -44,11 +44,11 @@ COPY ./requirements.txt requirements.txt
|
|||||||
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
RUN pip3 install --no-cache-dir --upgrade -r requirements.txt
|
||||||
|
|
||||||
# Copy everything else
|
# Copy everything else
|
||||||
COPY --chown=user ./src/ src/
|
COPY --chown=user ./server/ server/
|
||||||
|
|
||||||
# Copy frontend app and build
|
# Copy client app and build
|
||||||
COPY --chown=user ./frontend/ frontend/
|
COPY --chown=user ./client/ client/
|
||||||
RUN cd frontend && npm install && npm run build
|
RUN cd client && npm install && npm run build
|
||||||
|
|
||||||
# Start the FastAPI server
|
# Start the FastAPI server
|
||||||
CMD python3 src/bot_runner.py --port ${FAST_API_PORT}
|
CMD python3 server/bot_runner.py --port ${FAST_API_PORT}
|
||||||
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
@@ -57,7 +57,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Mount the static directory
|
# Mount the static directory
|
||||||
STATIC_DIR = "frontend/out"
|
STATIC_DIR = "client/out"
|
||||||
|
|
||||||
|
|
||||||
# ------------ Fast API Routes ------------ #
|
# ------------ Fast API Routes ------------ #
|
||||||
@@ -175,7 +175,7 @@ async def virtualize_bot(room_url: str, token: str):
|
|||||||
image = data[0]["config"]["image"]
|
image = data[0]["config"]["image"]
|
||||||
|
|
||||||
# Machine configuration
|
# 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()
|
cmd = cmd.split()
|
||||||
worker_props = {
|
worker_props = {
|
||||||
"config": {
|
"config": {
|
||||||