Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QOL patches #9

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ frontend/next-env.d.ts
aider_hints/
start_bot.json

storytelling-chatbot/
storytelling-chatbot/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ runpod.toml
aider_hints/
start_bot.json

.vscode/
.vscode/
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-tabs

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
args: ["--maxkb=2048"]
- id: check-ast
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
args: [--allow-multiple-documents]
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: "24.8.0"
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: "7.1.1"
hooks:
- id: flake8
additional_dependencies: ["pep8-naming"]
# Ignore all format-related checks as Black takes care of those.
args:
[
"--ignore",
"E2,W5,D100,D101",
"--select",
"E,W,F,N",
"--max-line-length=150",
]

- repo: https://github.com/pycqa/bandit
rev: 1.7.9
hooks:
- id: bandit
args: ["-iii", "-ll"]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--resolve-all-configs"]

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.0
hooks:
- id: commitizen
11 changes: 11 additions & 0 deletions .prow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
presubmits:
- name: pre-commit
decorate: true
skip_report: false
always_run: true
context: op1st/prow/pre-commit
spec:
containers:
- image: quay.io/thoth-station/pre-commit:v0.17.0
command:
- "prow-job-precommit"
40 changes: 0 additions & 40 deletions .vscode/launch.json

This file was deleted.

33 changes: 22 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,46 @@ ifneq (,$(wildcard ./.env))
export
endif

.PHONY: test bot participant deploy-bot fly-secrets fly-launch fly-build fly-deploy-bot docker-build-linux docker-run-bash docker-run-bot bot-with-prompt
# use `docker` as a CONTAINER_ENGINE or `podman` as a default to build container images
ifeq ($(shell which docker),)
CONTAINER_ENGINE := $(shell which podman)
else
CONTAINER_ENGINE := $(shell which docker)
endif

.PHONY: test
test:
# TEST_PATTERN="test_aggregators" make test
# PYTHONPATH=. pipenv run pytest -vrP $(if $(TEST_PATTERN),-k "$(TEST_PATTERN)",)
PYTHONPATH=. pipenv run pytest -vrP $(if $(TEST_PATTERN),-k "$(TEST_PATTERN)",) tests/

bot:
pipenv run python ./bot.py
.PHONY: bot
bot: bot.py
poetry run ./bot.py

bot-runner:
pipenv run env RUN_AS_PROCESS=true python ./bot_runner.py

.PHONY: participant
participant:
pipenv run python ./participant.py

docker-build:
docker build --tag=durandom/mds-moderator .
.PHONY: container-build container-build-linux container-run-bash container-run-bot
container-build:
$(CONTAINER_ENGINE) build --tag=durandom/mds-moderator .

docker-build-linux:
docker build --tag=durandom/mds-moderator --platform linux/amd64 .
container-build-linux:
$(CONTAINER_ENGINE) build --tag=durandom/mds-moderator --platform linux/amd64 .

docker-run-bash:
docker run -it --rm -v $(PWD):/app --platform linux/amd64 python:3.12.3-bookworm bash
container-run-bash:
$(CONTAINER_ENGINE) run -it --rm -v $(PWD):/app --platform linux/amd64 python:3.12.3-bookworm bash

docker-run-bot:
docker run -p 7860:7860 --env-file .env durandom/mds-moderator
container-run-bot:
$(CONTAINER_ENGINE) run -p 7860:7860 --env-file .env durandom/mds-moderator


# creates the new fly app
.PHONY: fly-secrets fly-launch fly-build fly-deploy fly-deploy-bot
fly-launch:
flyctl launch

Expand All @@ -50,6 +60,7 @@ fly-deploy-bot:
pipenv run python ./bot_runner.py --deploy-bot

# starts a bot with a prompt on fly.io
.PHONY: bot-with-prompt bot-with-prompt-local
bot-with-prompt:
curl --verbose --location --request POST "$${DEPLOYMENT_URL}/start_bot" \
--header 'Content-Type: application/json' \
Expand Down
5 changes: 2 additions & 3 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Notes
# Notes

* TTS: TextFrames have to end with punctuation, otherwise TTS will not kick in
* Don't add a processor twice to a pipeline


Du bist ein stiller Zuhoerer und antwortest nur wenn du explizit gefragt wirst. Es it ok auch nichts zu sagen. Antworte nicht, es sei denn du wirst explizit gefragt. Eine leere Antwort, also leerer text, ist in den meissten faellen die richtige reaktion.
Du bist ein stiller Zuhoerer und antwortest nur wenn du explizit gefragt wirst. Es it ok auch nichts zu sagen. Antworte nicht, es sei denn du wirst explizit gefragt. Eine leere Antwort, also leerer text, ist in den meissten faellen die richtige reaktion.
10 changes: 10 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See the OWNERS docs at https://go.k8s.io/owners

approvers:
- durandom
- goern

reviewers:
- durandom
- goern
- schwesig
14 changes: 7 additions & 7 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "*"
python-dotenv = "*"
boto3 = "*"
fastapi = "*"
uvicorn = "*"
pipecat-ai = {extras = ["silero,openai,daily,elevenlabs"], version = "*"}
python-dotenv = "*"
python-multipart = "*"
requests = "*"
torch = "==2.3.1"
torchaudio = "==2.3.1"
boto3 = "*"
python-multipart = "*"
pipecat-ai = {extras = ["silero,openai,daily,elevenlabs"], version = "*"}
uvicorn = "*"

[dev-packages]
pytest = "*"
Expand Down
51 changes: 35 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# AI Chatbot with Pipecat

This project implements an AI chatbot using the pipecat-ai framework. The bot can join a video call, understand speech, generate responses, and communicate using text-to-speech.
This project implements an AI chatbot using the pipecat-ai framework. The bot can join a video call, understand speech,
generate responses, and communicate using text-to-speech.

## Overview

The bot uses a pipeline architecture to process audio and video frames, transcribe speech, generate responses using a language model, and synthesize speech. It can interact with multiple participants in a video call, greeting them when they join and saying goodbye when they leave.
The bot uses a pipeline architecture to process audio and video frames, transcribe speech, generate responses using a
language model, and synthesize speech. It can interact with multiple participants in a video call, greeting them when
they join and saying goodbye when they leave.

## Key Components

Expand Down Expand Up @@ -42,27 +45,30 @@ If the `SYSTEM_PROMPT` environment variable is not set, the bot will use the def
To run the bot and participate in a conversation, you can use the provided Makefile:

1. To start the bot:
```
make bot
```

```bash
make bot
```

2. To join a participant from the command line:
```
make participant
```

```bash
make participant
```

3. Log into daily.co and join the video call using the provided link.
```
open $DAILY_SAMPLE_ROOM_URL
```

```bash
open $DAILY_SAMPLE_ROOM_URL
```

Make sure you have set up the necessary environment variables and dependencies before running these commands.

## Setup

```bash
pipenv install
```
### Dependencies

To install the dependencies, you can use `pipenv install` or `poetry install`. Do not forget to activate the virtual environment before running the bot.

## Configuration

Expand All @@ -71,10 +77,23 @@ pipenv install
The bot uses sprite animations for visual feedback. You can configure the sprite folder by setting the `SPRITE_FOLDER` environment variable. By default, it uses the "parkingmeter" folder. To use a different set of sprites, set the environment variable to the name of your desired folder within the `assets` directory.

Example:
```

```bash
export SPRITE_FOLDER=robot
```

### Environment Variables

Use the `.env` file to set the following environment variables:

```bash
DAILY_API_KEY=
ELEVENLABS_API_KEY=
FLY_API_KEY=
FLY_APP_NAME=
DEPLOYMENT_URL=
```

## Starting a Bot

You can start a bot using a simple curl command:
Expand Down Expand Up @@ -121,4 +140,4 @@ This feature allows for easy storage and retrieval of conversation logs, which c

## Notes

See the [NOTES.md](NOTES.md) file for additional information and notes on the project.
See the [NOTES.md](NOTES.md) file for additional information and notes on the project.
Loading