Skip to content

Commit

Permalink
sync-v0.0.4-fix (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
y1guo authored Dec 29, 2023
1 parent 13f601f commit 0b33929
Show file tree
Hide file tree
Showing 68 changed files with 15,456 additions and 9,684 deletions.
7 changes: 5 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
REBYTE_API_KEY=YOUR_API_KEY

# Option 2: Alternate LLM APIs
# Uncomment and configure the desired API
# Supported APIs: OpenAI, Anthropic, Anyscale, Local LLM with Openai Compatiable API
# Example values:
# OpenAI: "gpt-4", "gpt-3.5-turbo-16k", etc.
# Anthropic: "claude-instant-1", "claude-2", etc.
# Anyscale: "meta-llama/Llama-2-70b-chat-hf", etc.
# Local LLM: "localhost"
# LLM_MODEL_USE overwrites frontend choices! Leave empty unless you know what you're doing!
# LLM_MODEL_USE overwrites frontend choices! Leave empty unless you know what you're doing!
# LLM_MODEL_USE overwrites frontend choices! Leave empty unless you know what you're doing!
# LLM_MODEL_USE=gpt-3.5-turbo-16k

# API Keys
# Note that if not using ReByte, OPENAI_API_KEY is required for generating embeddings for
# Note that if not using ReByte, an OPENAI_API_KEY is required for generating embeddings for
# the knowledge base, no matter what LLM API is being used
# OPENAI_API_KEY=YOUR_API_KEY
# ANTHROPIC_API_KEY=YOUR_API_KEY
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ RUN chmod +x /realtime_ai_character/entrypoint.sh

# Run the application
CMD ["/bin/sh", "/realtime_ai_character/entrypoint.sh"]

21 changes: 21 additions & 0 deletions Dockerfile.postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use the official PostgreSQL image as a base
FROM postgres:14.1-alpine

# Install necessary packages to build the extension
RUN apk add --no-cache \
build-base \
git \
postgresql-dev

# Clone and build pgvector
RUN git clone https://github.com/ankane/pgvector.git \
&& cd pgvector \
&& make && make install

# Cleanup unnecessary packages after installation
RUN apk del build-base git postgresql-dev

RUN echo "CREATE EXTENSION vector;" > /docker-entrypoint-initdb.d/init-vector-extension.sql

# Set the shared preload libraries config
RUN echo "shared_preload_libraries='pgvector'" >> /var/lib/postgresql/data/postgresql.conf
237 changes: 116 additions & 121 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</p>

<div align="center">
<a href="https://discord.gg/YV4U7Am2Xn">
<a href="https://realchar.ai/join-discord">
<img src="https://img.shields.io/badge/discord-join%20chat-blue.svg?style=for-the-badge" alt="Join our Discord" height="20">
</a>
<a href="https://twitter.com/agishaun">
Expand Down Expand Up @@ -77,20 +77,122 @@ __Demo settings: Web, GPT4, ElevenLabs with voice clone, Chroma, Google Speech t
<img src="https://storage.googleapis.com/assistly/static/realchar/compare.png">
</div>

## 📀 Quick Start - Installation via Docker

## 👨‍🚀 Prerequisites
1. Create a new `.env` file
```sh
cp .env.example .env
```
Paste your API keys in `.env` file. A single [ReByte](#11-rebyte-api-key) or [OpenAI](#12-optional-openai-api-token) API key is enough to get started.

You can also configure other API keys if you have them.

Before setting up this project, follow these instructions to meet the prerequisites:
1. Start the app with `docker-compose.yaml`
```sh
docker compose up
```
If you have issues with docker (especially on a non-Linux machine), please refer to https://docs.docker.com/get-docker/ (installation) and https://docs.docker.com/desktop/troubleshoot/overview/ (troubleshooting).

1. Open http://localhost:3000 and enjoy the app!

### 1. Large Language Models
## 💿 Developers - Installation via Python
- **Step 1**. Clone the repo
```sh
git clone https://github.com/Shaunwei/RealChar.git && cd RealChar
```
- **Step 2**. Install requirements

Install [portaudio](https://people.csail.mit.edu/hubert/pyaudio/) and [ffmpeg](https://ffmpeg.org/download.html) for audio
```sh
# for mac
brew install portaudio
brew install ffmpeg
```
```sh
# for ubuntu
sudo apt update
sudo apt install portaudio19-dev
sudo apt install ffmpeg
```
Note:

- `ffmpeg>=4.4` is needed to work with `torchaudio>=2.1.0`

- Mac users may need to add ffmpeg library path to `DYLD_LIBRARY_PATH` for torchaudio to work:
```sh
export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
```

Then install all python requirements
```sh
pip install -r requirements.txt
```
If you need a faster local speech to text, install whisperX
```sh
pip install git+https://github.com/m-bain/whisperx.git
```
- **Step 3**. Create an empty [sqlite](https://www.sqlite.org/index.html) database if you have not done so before
```sh
sqlite3 test.db "VACUUM;"
```
- **Step 4**. Run db upgrade
```sh
alembic upgrade head
```
This ensures your database schema is up to date. Please run this after every time you pull the main branch.
- **Step 5**. Setup `.env`:
```sh
cp .env.example .env
```
Update API keys and configs following the instructions in the `.env` file.
> Note that some features require a working login system. You can get your own OAuth2 login for free with [Firebase](https://firebase.google.com/) if needed. To enable, set `USE_AUTH` to `true` and fill in the `FIREBASE_CONFIG_PATH` field. Also fill in Firebase configs in `client/next-web/.env`.
- **Step 6**. Run backend server with `cli.py` or use uvicorn directly
```sh
python cli.py run-uvicorn
# or
uvicorn realtime_ai_character.main:app
```
- **Step 7**. Run frontend client:
- web client:

Create an `.env` file under `client/next-web/`
```sh
cp client/next-web/.env.example client/next-web/.env
```
Adjust `.env` according to the instruction in `client/next-web/README.md`.

Start the frontend server:
```sh
python cli.py next-web-dev
# or
cd client/next-web && npm run dev
# or
cd client/next-web && npm run build && npm run start
```
After running these commands, a local development server will start, and your default web browser will open a new tab/window pointing to this server (usually http://localhost:3000).
- (Optional) Terminal client:

Run the following command in your terminal
```sh
python client/cli.py
```
- (Optional) mobile client:

open `client/mobile/ios/rac/rac.xcodeproj/project.pbxproj` in Xcode and run the app
- **Step 8**. Select one character to talk to, then start talking. Use **GPT4** for better conversation and **Wear headphone** for best audio(avoid echo)

Note if you want to remotely connect to a RealChar server, SSL set up is required to establish the audio connection.

## 👨‍🚀 API Keys and Configurations

### 1. LLMs

### 1.1 ReByte API Key
To get your ReByte API key, follow these steps:

1. Go to the [ReByte website](https://rebyte.ai/) and sign up for an account if you haven't already.
1. Once you're logged in, go to Settings > API Keys.
1. Generate a new API key by clicking on the "Generate" button.
1. Prepare to use it during configuration.

### 1.2 (Optional) OpenAI API Token
<details><summary>👇click me</summary>
Expand All @@ -101,7 +203,6 @@ To get your OpenAI API token, follow these steps:
1. Go to the [OpenAI website](https://beta.openai.com/signup/) and sign up for an account if you haven't already.
1. Once you're logged in, navigate to the [API keys page](https://beta.openai.com/account/api-keys).
1. Generate a new API key by clicking on the "Create API Key" button.
1. Prepare to use it during configuration.

(Optional) To use Azure OpenAI API instead, refer to the following section:

Expand Down Expand Up @@ -135,7 +236,6 @@ To get your Anthropic API token, follow these steps:
1. Go to the [Anthropic website](https://docs.anthropic.com/claude/docs/getting-started-with-claude) and sign up for an account if you haven't already.
1. Once you're logged in, navigate to the [API keys page](https://console.anthropic.com/account/keys).
1. Generate a new API key by clicking on the "Create Key" button.
1. Prepare to use it during configuration.
</details>

### 1.4 (Optional) Anyscale API Token
Expand All @@ -146,12 +246,11 @@ To get your Anyscale API token, follow these steps:
1. Go to the [Anyscale website](https://www.anyscale.com/) and sign up for an account if you haven't already.
1. Once you're logged in, navigate to the [Credentials page](https://app.endpoints.anyscale.com/credentials).
1. Generate a new API key by clicking on the "Generate credential" button.
1. Prepare to use it during configuration.
</details>

### 2. Speech to Text

We support [whisperX](https://github.com/m-bain/whisperX) as the local speech to text engine. Work with CPU and NVIDIA GPU.
We support [faster-whisper](https://github.com/SYSTRAN/faster-whisper) and [whisperX](https://github.com/m-bain/whisperX) as the local speech to text engines. Work with CPU and NVIDIA GPU.

### 2.1 (Optional) Google Speech-to-Text API
<details><summary>👇click me</summary>
Expand All @@ -160,12 +259,14 @@ To get your Google Cloud API credentials.json, follow these steps:

1. Go to the [GCP website](https://cloud.google.com/speech-to-text/docs/before-you-begin) and sign up for an account if you haven't already.
2. Follow the guide to create a project and enable Speech to Text API
3. Put `google_credentials.json` in the root folder of this project. Check [GCP website](https://cloud.google.com/speech-to-text/docs/before-you-begin#set_your_authentication_environment_variable)
3. Put `google_credentials.json` in the root folder of this project. Check [Create and delete service account keys](https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-console)
4. Change `SPEECH_TO_TEXT_USE` to use `GOOGLE` in your `.env` file
</details>
### 2.2 (Optional) OpenAI Whisper API
<details><summary>👇click me</summary>
Same as [OpenAI API Token](#12-optional-openai-api-token)
</details>
### 3. Text to Speech
Expand All @@ -180,126 +281,20 @@ Edge TTS is the default and is free to use.
Visit [ElevenLabs](https://beta.elevenlabs.io/) to create an account. You'll need this to access the text to speech and voice cloning features.

1. In your Profile Setting, you can get an API Key.
1. Prepare to use it during configuration.

</details>

### 3.2 (Optional) Google Text-to-Speech API

## 💿 Installation via Python
- **Step 1**. Clone the repo
```sh
git clone https://github.com/Shaunwei/RealChar.git && cd RealChar
```
- **Step 2**. Install requirements

Install [portaudio](https://people.csail.mit.edu/hubert/pyaudio/) and [ffmpeg](https://ffmpeg.org/download.html) for audio
```sh
# for mac
brew install portaudio
brew install ffmpeg
```
```sh
# for ubuntu
sudo apt update
sudo apt install portaudio19-dev
sudo apt install ffmpeg
```
Note:

- `ffmpeg>=4.4` is needed to work with `torchaudio>=2.1.0`

- Mac users may need to add ffmpeg library path to `DYLD_LIBRARY_PATH` for torchaudio to work:
```sh
export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
```

Then install all python requirements
```sh
pip install -r requirements.txt
```
If you need a faster local speech to text, install whisperX
```sh
pip install git+https://github.com/m-bain/whisperx.git
```
- **Step 3**. Create an empty [sqlite](https://www.sqlite.org/index.html) database if you have not done so before
```sh
sqlite3 test.db "VACUUM;"
```
- **Step 4**. Run db upgrade
```sh
alembic upgrade head
```
This ensures your database schema is up to date. Please run this after every time you pull the main branch.
- **Step 5**. Setup `.env`:
```sh
cp .env.example .env
```
Update API keys and configs following the instructions in the `.env` file.
> Note that some features require a working login system. You can get your own OAuth2 login for free with [Firebase](https://firebase.google.com/) if needed. To enable, set `USE_AUTH` to `true` and fill in the `FIREBASE_CONFIG_PATH` field. Also fill in Firebase configs in `client/next-web/.env`.
- **Step 6**. Run backend server with `cli.py` or use uvicorn directly
```sh
python cli.py run-uvicorn
# or
uvicorn realtime_ai_character.main:app
```
- **Step 7**. Run frontend client:
- web client:

Create an `.env` file under `client/next-web/`
```sh
cp client/next-web/.env.example client/next-web/.env
```
Adjust `.env` according to the instruction in `client/next-web/README.md`.

Start the frontend server:
```sh
python cli.py next-web-dev
# or
cd client/next-web && npm run dev
# or
cd client/next-web && npm run build && npm run start
```
After running these commands, a local development server will start, and your default web browser will open a new tab/window pointing to this server (usually http://localhost:3000).
- (Optional) Terminal client:

Run the following command in your terminal
```sh
python client/cli.py
```
- (Optional) mobile client:

open `client/mobile/ios/rac/rac.xcodeproj/project.pbxproj` in Xcode and run the app
- **Step 8**. Select one character to talk to, then start talking. Use **GPT4** for better conversation and **Wear headphone** for best audio(avoid echo)

Note if you want to remotely connect to a RealChar server, SSL set up is required to establish the audio connection.

## (Optional) 📀 Installation via Docker
<details><summary>👇click me</summary>

1. Initialize and update the database
```sh
sqlite3 test.db "VACUUM;"
alembic upgrade head
```

1. Configure `.env`
```sh
cp .env.example .env
```
Update API keys and configs following the instructions in the `.env` file.

1. Start the app with `docker-compose.yaml`
```sh
docker compose up
```
If you have issues with docker (especially on a non-Linux machine), please refer to https://docs.docker.com/get-docker/ (installation) and https://docs.docker.com/desktop/troubleshoot/overview/ (troubleshooting).
To get your Google Cloud API credentials.json, follow these steps:

1. Open http://localhost:3000 to access the web app
1. Go to the [GCP website](https://cloud.google.com/text-to-speech/docs/quickstart-client-libraries) and sign up for an account if you haven't already.
2. Follow the guide to create a project and enable Text to Speech API
3. Put `google_credentials.json` in the root folder of this project. Check [Create and delete service account keys](https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-console)
</details>
<br/>

## (Optional) 🔥 Create Your Own Characters
<details><summary>👇click me</summary>
Expand Down Expand Up @@ -373,4 +368,4 @@ Please check out our [Contribution Guide](contribute.md)!
</a>

## 🎲 Community
- Join us on [Discord](https://discord.gg/YV4U7Am2Xn)
- Join us on [Discord](https://realchar.ai/join-discord)
2 changes: 0 additions & 2 deletions client/next-web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

# zustand lib force to add
!./lib
19 changes: 17 additions & 2 deletions client/next-web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {
async redirects() {
return [
{
source: '/join-discord',
destination: 'https://discord.gg/e4AYNnFg2F',
permanent: false,
},
{
source: '/feedback',
destination: 'https://github.com/ReByteAI/bug-tracker',
permanent: false,
},
];
},
};

module.exports = nextConfig
module.exports = nextConfig;
Loading

0 comments on commit 0b33929

Please sign in to comment.