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

Update README-CN.md #135

Merged
merged 1 commit into from
Jul 30, 2024
Merged
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
129 changes: 42 additions & 87 deletions docs/readmes/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
[![GitHub forks](https://img.shields.io/github/forks/rte-design/astra.ai?style=social&label=Fork)](https://GitHub.com/rte-design/astra.ai/network/?WT.mc_id=academic-105485-koreyst)
[![GitHub stars](https://img.shields.io/github/stars/rte-design/astra.ai?style=social&label=Star)](https://GitHub.com/rte-design/astra.ai/stargazers/?WT.mc_id=academic-105485-koreyst)

<a href="./README.md"><img alt="README in English" src="https://img.shields.io/badge/English-lightgrey"></a>
<a href="./docs/readmes/README-CN.md"><img alt="简体中文" src="https://img.shields.io/badge/简体中文-lightgrey"></a>
<a href="../../README.md"><img alt="README in English" src="https://img.shields.io/badge/English-lightgrey"></a>
<a href="../readmes/README-CN.md"><img alt="简体中文" src="https://img.shields.io/badge/简体中文-lightgrey"></a>
</div>

<div align="center">
Expand Down Expand Up @@ -63,80 +63,68 @@ $ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
```

#### 1. 在 Docker 镜像中构建 agent
#### 1.创建 manifest 配置文件
从示例文件创建 manifest:

```bash
# 从示例文件创建 manifest
cp ./agents/manifest.json.example ./agents/manifest.json
```

# 拉取带有开发工具的 Docker 镜像,并将当前文件夹挂载为工作区
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

# 进入 Docker 镜像
docker exec -it astra_agents_dev bash
#### 2. 基本配置

# 构建 agent
make build
在 manifest 里面找到下列属性替换:
```json
"app_id": "<agora_appid>"
"api_key": "<openai_api_key>"
"agora_asr_vendor_key": "<azure_stt_key>"
"agora_asr_vendor_region": "<azure_stt_region>"
"azure_subscription_key": "<azure_tts_key>"
"azure_subscription_region": "<azure_tts_region>"
```

#### 2. 改动 prompts
上述代码生成了一个代理可执行文件。要自定义提示和 OpenAI 参数,请修改 `agents/addon/extension/openai_chatgpt/openai_chatgpt.go` 中的以下代码:

```go
func defaultOpenaiChatGPTConfig() openaiChatGPTConfig {
return openaiChatGPTConfig{
BaseUrl: "https://api.openai.com/v1",
ApiKey: "",
Model: openai.GPT4o,
Prompt: "You are a voice assistant who talks in a conversational way and can chat with me like my friends. i will speak to you in english or chinese, and you will answer in the corrected and improved version of my text with the language i use. Don't talk like a robot, instead i would like you to talk like real human with emotions. i will use your answer for text-to-speech, so don't return me any meaningless characters. I want you to be helpful, when i'm asking you for advices, give me precise, practical and useful advices instead of being vague. When giving me list of options, express the options in a narrative way instead of bullet points.",
FrequencyPenalty: 0.9,
PresencePenalty: 0.9,
TopP: 1.0,
Temperature: 0.1,
MaxTokens: 512,
Seed: rand.Int(),
ProxyUrl: "",
}
#### 3. 定制化
在 manifest 可以直接改 propmt 和问候语:
```json
"property": {
"base_url": "",
"api_key": "<openai_api_key>",
"frequency_penalty": 0.9,
"model": "gpt-3.5-turbo",
"max_tokens": 512,
"prompt": "",
"proxy_url": "",
"greeting": "ASTRA agent connected. How can i help you today?",
"max_memory_length": 10
}
```

#### 3. 启动本地服务器
#### 4. 在 Docker 镜像中构建 agent

通过运行以下终端命令启动服务器
打开 Terminal, 跑下列命令

```bash
# Agora App ID and Agora App Certificate
export AGORA_APP_ID=<your_agora_appid>
export AGORA_APP_CERTIFICATE=<your_agora_app_certificate>
# 拉取带有开发工具的 Docker 镜像,并将当前文件夹挂载为工作区
docker run -itd -v $(pwd):/app -w /app -p 8080:8080 --name astra_agents_dev ghcr.io/rte-design/astra_agents_build

# OpenAI API key
export OPENAI_API_KEY=<your_openai_api_key>
# 对于 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

# Azure STT key and region
export AZURE_STT_KEY=<your_azure_stt_key>
export AZURE_STT_REGION=<your_azure_stt_region>
# 进入 Docker 容器
docker exec -it astra_agents_dev bash

# TTS
# Here are three TTS options, either one will work
# Make sure to comment out the one you don't use
# 在容器里构建 agent
make build
```

# 1. using Azure
export TTS_VENDOR_CHINESE=azure
export AZURE_TTS_KEY=<your_azure_tts_key>
export AZURE_TTS_REGION=<your_azure_tts_region>
#### 5. 启动本地服务器

# 2. using ElevenLabs
export TTS_VENDOR_ENGLISH=elevenlabs
export ELEVENLABS_TTS_KEY=<your_elevanlabs_tts_key>

```bash
# Agent is ready to start on port 8080
make run-server
```

#### 4. 运行 voice agent 界面
#### 6. 运行 voice agent 界面

voice agent 界面是基于 NextJS 14 构建的,因此需要 Node 18 或更高版本。

Expand All @@ -149,7 +137,7 @@ cp .env.example .env
npm install && npm run dev
```

#### 5. 验证您定制的 voice agent 🎉
#### 7. 验证您定制的 voice agent 🎉

在浏览器中打开 `localhost:3000`,您应该能够看到一个与示例项目一样的 voice angent,但是这次是带有定制的 voice agent。

Expand All @@ -172,39 +160,6 @@ npm install && npm run dev
![ASTRAvoice agent架构图](../../images/image-2.png)


<br>
<h2>搭建无界面的 voice agent</h2>

#### 1. 在 Docker 镜像中搭建 voice agent

```
# 从示例文件创建 manifest
cp ./agents/manifest.json.example ./agents/manifest.json

# 拉取带有开发工具的 Docker 镜像,并将当前文件夹挂载为工作区
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

# 进入 Docker 镜像
docker exec -it astra_agents_dev bash

# 构建 agent
make build

# 启动 agent
cd ./agents && ./bin/start
```

#### 2. 测试 voice agent

前往 [Agora Web Demo](https://webdemo.agora.io/) 进行快速测试。

请注意,`channel` 和 `remote_stream_id` 需要与您在 `https://webdemo.agora.io/` 上使用的一致。

输入相应的 RTC ID 和频道名称后,您应该能够看到日志并听到音频输出。

<br>
<h2>ASTRA 服务</h2>

Expand Down