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

feat(): support docker-compose #123

Merged
merged 5 commits into from
Jul 26, 2024
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bin/
core
crash_context_v1
.deps/
docker-compose.yml
.DS_Store
.env
/.gn
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ WORKDIR /app

COPY . .
COPY agents/manifest.json.example agents/manifest.json
# COPY agents/manifest.json.elevenlabs.example agents/manifest.elevenlabs.json
COPY agents/manifest.json.cn.example agents/manifest.cn.json
COPY agents/manifest.json.en.example agents/manifest.en.json
COPY agents/manifest.json.elevenlabs.example agents/manifest.elevenlabs.json
COPY agents/${SESSION_CONTROL_CONF} agents/session_control.conf

RUN make build && \
Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PROJECT_NAME := astra
PROJECT_VERSION ?= "0.1."$(shell date -u +'%Y%m%d%H')
REGISTRY ?= agoraio/

.PHONY: build build-agents build-server docker-build-server run-server
.PHONY: build build-agents build-playground build-server clean clean-agents docker-build-playground docker-build-server run-server

build: build-agents build-server

Expand All @@ -11,6 +11,11 @@ build-agents:
cd agents && ./scripts/install_deps_and_build.sh linux x64 && mv bin/main bin/worker
@echo ">> done"

build-playground:
@echo ">> build playground"
cd playground && npm i && npm run build
@echo ">> done"

build-server:
@echo ">> build server"
cd server && go mod tidy && go mod download && go build -o bin/api main.go
Expand All @@ -23,9 +28,14 @@ clean-agents:
rm -rf agents/manifest.json agents/bin agents/out agents/interface agents/include agents/lib agents/lib64 agents/addon/system agents/addon/extension_group agents/.release
@echo ">> done"

docker-build-playground:
@echo ">> docker build playground"
cd playground && docker build -t $(REGISTRY)$(PROJECT_NAME)_playground:$(PROJECT_VERSION) -f Dockerfile .
@echo ">> done"

docker-build-server:
@echo ">> docker build server"
docker build -t $(REGISTRY)$(PROJECT_NAME):$(PROJECT_VERSION) --platform linux/amd64 -f Dockerfile .
docker build -t $(REGISTRY)$(PROJECT_NAME)_agents_server:$(PROJECT_VERSION) --platform linux/amd64 -f Dockerfile .
@echo ">> done"

run-server:
Expand Down
65 changes: 13 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,20 @@ To start, make sure you have:
- Azure's [speech-to-text](https://azure.microsoft.com/en-us/products/ai-services/speech-to-text) and [text-to-speech](https://azure.microsoft.com/en-us/products/ai-services/text-to-speech) API keys
- [OpenAI](https://openai.com/index/openai-api/) API key
- [Docker](https://www.docker.com/)
- [Docker Compose](https://docs.docker.com/compose/)

```bash
# Run the pre-built agent image
docker run --restart=always -itd -p 8080:8080 \
-v /tmp:/tmp \
-e AGORA_APP_ID=<your_agora_appid> \
-e AGORA_APP_CERTIFICATE=<your_agora_app_certificate> \
-e AZURE_STT_KEY=<your_azure_stt_key> \
-e AZURE_STT_REGION=<your_azure_stt_region> \
-e OPENAI_API_KEY=<your_openai_api_key> \
-e AZURE_TTS_KEY=<your_azure_tts_key> \
-e AZURE_TTS_REGION=<your_azure_tts_region> \
--name astra_agents_server \
agoraio/astra_agents_server:latest

# Here are two TTS options, either one will work
# Make sure to comment out the one you don't use
# 1. using Azure
-e TTS_VENDOR_CHINESE=azure
-e AZURE_TTS_KEY=<your_azure_tts_key>
-e AZURE_TTS_REGION=<your_azure_tts_region>

# 2. using ElevenLabs
-e TTS_VENDOR_ENGLISH=elevenlabs
-e ELEVENLABS_TTS_KEY=<your_elevanlabs_tts_key>
# Copy the docker-compose.yml.example file to a new file named docker-compose.yml
plutoless marked this conversation as resolved.
Show resolved Hide resolved
# remember to provide your api keys in your docker-compose.yml file
cp ./docker-compose.yml.example ./docker-compose.yml
# Execute docker compose up to start the services
docker compose up
```

This should start an agent server running on port 8080.
This should start an playground running on port 3000 and agent server running on port 8080.
<br>
🎉 Congratulations! You now have a ASTRA powered voice agent running locally, access the DASTRA in your browser at http://localhost:3000


#### Mac with Apple Silicon

Expand All @@ -92,23 +78,6 @@ You will need to uncheck "Use Rosetta for x86_64/amd64 emulation on apple silico

</div>

<h3>Connect to Your Agent</h3>

You can use the showcase voice agent, in `/playground` folder, to test with the server you just started.

The project is built on NextJS 14, hence it needs Node 18 or later.

```bash
# Set up an .env file
cp ./playground/.env.example ./playground/.env
cd playground

# Install npm dependencies & start
npm i && npm run dev
```

🎉 Congratulations! You now have a ASTRA powered voice agent running locally.

<br>
<h2>Agent Customization</h2>

Expand Down Expand Up @@ -137,8 +106,7 @@ You need to prepare the proper `manifest.json` file first.
```bash
# Rename manifest example
cp ./agents/manifest.json.example ./agents/manifest.json
cp ./agents/manifest.json.en.example ./agents/manifest.en.json
cp ./agents/manifest.json.cn.example ./agents/manifest.cn.json
cp ./agents/manifest.json.elevenlabs.example ./agents/manifest.json.elevenlabs.example

# pull the docker image with dev tools and mount your current folder as workspace
docker run -itd -v $(pwd):/app -w /app -p 8080:8080 --name astra_agents_dev ghcr.io/rte-design/astra_agents_build
Expand All @@ -160,15 +128,13 @@ The above code generates an agent executable. To customize your prompts and Open
Once you have made the necessary changes, you can use the following commands to start a server. You can then test it out using the ASTRA voice agent from the showcase.

```bash
# TODO: need to refactor the contents
# TODO: need to refactor the contents
# Agora App ID and Agora App Certificate
export AGORA_APP_ID=<your_agora_appid>
export AGORA_APP_CERTIFICATE=<your_agora_app_certificate>

# OpenAI API key
export OPENAI_API_KEY=<your_openai_api_key>
# Or QWEN key
export QWEN_API_KEY=<your_qwern_api_key>

# Azure STT key and region
export AZURE_STT_KEY=<your_azure_stt_key>
Expand All @@ -187,11 +153,7 @@ export AZURE_TTS_REGION=<your_azure_tts_region>
export TTS_VENDOR_ENGLISH=elevenlabs
export ELEVENLABS_TTS_KEY=<your_elevanlabs_tts_key>

# 3. using Cosy
export COSY_TTS_KEY=<your_cosy_tts_key>

# agent is ready to start on port 8080

make run-server
```

Expand All @@ -204,8 +166,7 @@ The default agent control is managed via server gateway. For quick testing, you

# rename manifest example
cp ./agents/manifest.json.example ./agents/manifest.json
cp ./agents/manifest.json.en.example ./agents/manifest.en.json
cp ./agents/manifest.json.cn.example ./agents/manifest.cn.json
cp ./agents/manifest.json.elevenlabs.example ./agents/manifest.json.elevenlabs.example

# pull the docker image with dev tools and mount your current folder as workspace
docker run -itd -v $(pwd):/app -w /app -p 8080:8080 --name astra_agents_dev ghcr.io/rte-design/astra_agents_build
Expand Down
Loading