Skip to content

Commit

Permalink
Feature/seperate graphs (#159)
Browse files Browse the repository at this point in the history
* feat: upgrade runtime 0.4.0 with build pass

* fix: compatible with runtime 0.4.0

* feat: use property for predefined_graphs

* fix: type

* Feature/seperate graphs (#147)

* chore(): update devcontainer.json with additional VS Code extensions and settings for c++/golang/python

* feat(): configuration uses .env, supporting dynamic setting of Graph

* fix(): fix

* fix(): fix type

* chore(): specify platform

* chore(): adjust manifest.json to property.json

* chore(): modify docker-compose.yml

* chore(): restore the previous VSCode extensions

* chore(): delete property.json.graphs_examples

* chore(): rename PROXY_URL to OPENAI_PROXY_URL

* chore(): support graph designer (#151)

* chore(): support graph designer

* chore(): keep SERVER_PORT

* chore(): modify comment

* Feature/seperate graphs (#153)

* chore(): merge all manifest.json.example into property.json.example

* chore(): remove version

* chore(): remove the pcm_frame under the agora_rtc extension

* chore(): adjust README (#154)

* fix: fix readme

* fix: readme update

* chore(): default start graph designer server (#156)

* chore(): default start graph designer server

* chore(): update image version

* chore(): merge commit 09ca830, PR 127 (#157)

Co-authored-by: Bin Chen <[email protected]>

* feat: upgrade build image version

* fix: fix polly folder name & readme

* feat: readme update

---------

Co-authored-by: Jay Zhang <[email protected]>
Co-authored-by: sunshinexcode <[email protected]>
Co-authored-by: Bin Chen <[email protected]>
  • Loading branch information
4 people authored Aug 5, 2024
1 parent 1e1cc87 commit 38e1738
Show file tree
Hide file tree
Showing 65 changed files with 2,197 additions and 2,060 deletions.
23 changes: 8 additions & 15 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,22 @@
{
"name": "astra",
"image": "ghcr.io/rte-design/astra_agents_build",

"customizations": {
"vscode": {
"extensions": ["golang.go"]
"extensions": [
"golang.go"
]
}
},

"workspaceMount": "source=${localWorkspaceFolder},target=/app,type=bind",
"workspaceMount": "source=${localWorkspaceFolder},target=/app,type=bind",
"workspaceFolder": "/app",

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8080],

"forwardPorts": [
8080,
49483
],
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/git:1": {}
}

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": ""

// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
67 changes: 67 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# ------------------------------
# Environment Variables for server & worker
# ------------------------------

# ------------------------------
# Server Configuration
# ------------------------------

# Log path
LOG_PATH=/tmp
# Graph designer server port
GRAPH_DESIGNER_SERVER_PORT=49483
# Server port
SERVER_PORT=8080
# Maximum number of workers
WORKERS_MAX=100
# Worker quit timeout in seconds
WORKER_QUIT_TIMEOUT_SECONDES=60

# Agora App ID and Agora App Certificate
# required: this variable must be set
AGORA_APP_ID=
AGORA_APP_CERTIFICATE=

# ------------------------------
# Worker Configuration
# ------------------------------

# Extension: bedrock_llm
# Extension: polly_tts
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_BEDROCK_MODEL=
AWS_REGION=

# Extension: agora_rtc
# Azure STT key and region
AZURE_STT_KEY=
AZURE_STT_REGION=

# Extension: azure_tts
# Azure TTS key and region
AZURE_TTS_KEY=
AZURE_TTS_REGION=

# Extension: cosy_tts
# Cosy TTS key
COSY_TTS_KEY=

# Extension: elevenlabs_tts
# ElevenLabs TTS key
ELEVENLABS_TTS_KEY=

# Extension: openai_chatgpt
# OpenAI API key
OPENAI_API_KEY=
# OpenAI base URL
# if using OpenAI, keep default. using other OpenAI-compatible providers, then set it to the other provider's address
OPENAI_BASE_URL=
# OpenAI Model
OPENAI_MODEL=gpt-4o-mini
# OpenAI proxy URL
OPENAI_PROXY_URL=

# Extension: qwen_llm
# Qwen API key
QWEN_API_KEY=
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bin/
core
crash_context_v1
.deps/
docker-compose.yml
.DS_Store
.env
/.gn
Expand All @@ -22,11 +21,6 @@ include/
interface/
lib/
lib64
agents/manifest.json
agents/manifest.elevenlabs.json
agents/manifest.cn.json
agents/manifest.en.json
!agents/addon/manifest.json
node_modules/
/out/
*.pcm
Expand All @@ -37,4 +31,4 @@ xdump_config
speechsdk/
SpeechSDK-Linux.tar.gz
pyvenv.cfg
xdump_config
xdump_config
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM ghcr.io/rte-design/astra_agents_build:0.3.3 AS builder
FROM ghcr.io/rte-design/astra_agents_build:0.3.5 AS builder

ARG SESSION_CONTROL_CONF=session_control.conf

WORKDIR /app

COPY . .
COPY agents/manifest.json.example agents/manifest.json
COPY agents/manifest.json.elevenlabs.example agents/manifest.elevenlabs.json
COPY agents/property.json.example agents/property.json
COPY agents/${SESSION_CONTROL_CONF} agents/session_control.conf

RUN make build && \
RUN make clean && make build && \
cd agents && ./scripts/package.sh

FROM ubuntu:22.04
Expand Down
9 changes: 7 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-playground build-server clean clean-agents docker-build-playground docker-build-server run-server
.PHONY: build build-agents build-playground build-server clean clean-agents docker-build-playground docker-build-server run-gd-server run-server

build: build-agents build-server

Expand All @@ -25,7 +25,7 @@ clean: clean-agents

clean-agents:
@echo ">> 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
rm -rf 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:
Expand All @@ -38,6 +38,11 @@ docker-build-server:
docker build -t $(REGISTRY)$(PROJECT_NAME)_agents_server:$(PROJECT_VERSION) --platform linux/amd64 -f Dockerfile .
@echo ">> done"

run-gd-server:
@echo ">> run graph designer server"
cd agents && arpm dev-server
@echo ">> done"

run-server:
@echo ">> run server"
server/bin/api
Expand Down
100 changes: 37 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We showcase an impressive voice agent called Astra, powered by TEN, demonstratin
- Agora App ID and App Certificate([read here on how](https://docs.agora.io/en/video-calling/get-started/manage-agora-account?platform=web))
- 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](https://www.docker.com/) / [Docker Compose](https://docs.docker.com/compose/)
- [Node.js(LTS) v18](https://nodejs.org/en)

#### Docker setting on apple silicon
Expand All @@ -58,85 +58,59 @@ You will need to uncheck "Use Rosetta for x86_64/amd64 emulation on apple silico
</div>


#### 1. Create manifest.json
#### 1. Prepare config files

```bash
# Create manifest.json from the example
cp ./agents/manifest.json.example ./agents/manifest.json
# Create property.json from the example
cp ./agents/property.json.example ./agents/property.json
# Create .env from the example
cp ./.env.example ./.env
```

#### 2. Modify prompt and greeting

```js
// Feel free to edit prompt and greeting in manifest.json
"property": {
"base_url": "",
"api_key": "<openai_api_key>",
"frequency_penalty": 0.9,
"model": "gpt-3.5-turbo",
"max_tokens": 512,
"prompt": "", // prompt
"proxy_url": "",
"greeting": "Astra agent connected. How can I help you today?", // greeting
"max_memory_length": 10
}
#### 2. Setup API keys & Environment varialbes in .env file
```
...
# Agora App ID and Agora App Certificate
# required: this variable must be set
AGORA_APP_ID=
AGORA_APP_CERTIFICATE=
...
# Extension: agora_rtc
# Azure STT key and region
AZURE_STT_KEY=
AZURE_STT_REGION=
#### 3. Create agent in Docker container

```bash
# In CLI, pull Docker image and mount the target directory
docker run -itd -v $(pwd):/app -w /app -p 8080:8080 --name astra_agents_dev ghcr.io/rte-design/astra_agents_build

# Windows Git Bash
# docker run -itd -v //$(pwd):/app -w //app -p 8080:8080 --name astra_agents_dev ghcr.io/rte-design/astra_agents_build

# Enter container
docker exec -it astra_agents_dev bash

# Create agent
make build
# Extension: azure_tts
# Azure TTS key and region
AZURE_TTS_KEY=
AZURE_TTS_REGION=
...
# Extension: openai_chatgpt
# OpenAI API key
OPENAI_API_KEY=
```

#### 4. Export env variables and start server

#### 3. Start agent builder toolkit containers

```bash
# In the same CLI window, set env variables
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>

# Azure STT key and region
export AZURE_STT_KEY=<your_azure_stt_key>
export AZURE_STT_REGION=<your_azure_stt_region>

# Azure TTS key and region
export AZURE_TTS_KEY=<your_azure_tts_key>
export AZURE_TTS_REGION=<your_azure_tts_region>

# Run server on port 8080
make run-server
# Execute docker compose up to start the services
docker compose up
```

#### 5. Connect voice agent UI to server

Open a separate Terminal tab and run the commands:
#### 4. Build your agent and start server

```bash
# Create a .env file from example
cd playground
cp .env.example .env
# Enter container to build agent
docker exec -it astra_agents_dev bash
make build

# Install dependencies and start dev environment in localhost:3000
npm install && npm run dev
# Run server on port 8080
make run-server
```

#### 6. Verify your customized voice agent 🎉
#### 5. Verify your voice agent 🎉

Open `localhost:3000` in your browser, you should be seeing a voice agent just like the Astra, yet with your own customizations.
You can open `localhost:3000` in your browser to test your own agent, or open `localhost:3001` in your browser to build your workflow by Graph Designer.

<br>
<h2>Voice agent architecture </h2>
Expand Down Expand Up @@ -192,4 +166,4 @@ Contributions are welcome! Please read the [contribution guidelines](CONTRIBUTIN
<br>
<h2>License</h2>

This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
1 change: 1 addition & 0 deletions agents/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ session_control.conf.agora
xdump_config
.vscode
*.pyc
property.json
6 changes: 3 additions & 3 deletions agents/addon/extension/azure_tts/manifest.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"type": "extension",
"name": "azure_tts",
"version": "0.2.0",
"version": "0.4.0",
"language": "cpp",
"dependencies": [
{
"type": "system",
"name": "rte_runtime",
"version": "0.3.1"
"version": "0.4.0"
},
{
"type": "system",
"name": "azure_speech_sdk",
"version": "1.38.0"
}
}
],
"api": {
"property": {
Expand Down
Loading

0 comments on commit 38e1738

Please sign in to comment.