fix: the spell of keywords

This commit is contained in:
WJG 2024-02-29 23:31:16 +08:00
parent 76950eb3d9
commit c704999a78
No known key found for this signature in database
GPG Key ID: 258474EF8590014A
2 changed files with 12 additions and 11 deletions

View File

@ -12,7 +12,7 @@
- **LLM 回答**。让小爱音箱使用 [ChatGPT](https://chat.openai.com) 等大模型回答消息,更懂你。
- **角色扮演**。为你的小爱音箱赋予人格,秒变你的魅力女友 or 知心闺蜜。
- **IoT Agent**。自动控制米家设备,比如你说心情不好时会自动帮你播放轻松舒缓的音乐调节灯光变柔和等TODO
- **自动控制米家设备**。比如:当你说心情不好时会自动帮你播放轻松舒缓的音乐调节灯光变柔和等TODO
- **流式响应**。秒回消息,爱你,不会让你等太久。
- **自定义 TTS**。厌倦了小爱同学的语音?帮你解锁[「豆包」](https://doubao.com)同款音色。
@ -28,10 +28,11 @@
#### 📦 Docker
对于电脑小白或者不想自己配置代码运行环境Node的同学请参考 Docker 启动方式。
对于电脑小白或者不想自己配置代码运行环境Node的同学可以使用 Docker 启动方式。
请先按照[「配置参数」](#%EF%B8%8F-配置参数)章节,配置好你的 `.env``.migpt.js` 文件。然后使用以下命令启动 docker
```shell
# 请先按照「配置参数」章节,配置好你的 `.env``.migpt.js` 文件
docker run -d --env-file $(pwd)/.env \
-v $(pwd)/.migpt.js:/usr/src/app/.migpt.js \
idootop/mi-gpt:1.0.0
@ -45,7 +46,7 @@ docker run -d --env-file $(pwd)/.env \
npm install mi-gpt # 安装依赖
```
然后,创建并启动 `MiGPT` 实例。初始化参数说明,请看下面的[配置参数](#%EF%B8%8F-配置参数)。
然后,创建并启动 `MiGPT` 实例。初始化参数请看下面的[配置参数](#%EF%B8%8F-配置参数)章节
```typescript
import { MiGPT } from "mi-gpt";
@ -113,7 +114,7 @@ main();
| `did` | 小爱音箱 ID 或名称 | `"小爱音箱 Pro"` |
| **其他(可选)** | | |
| `callAIPrefix` | 当消息以召唤关键词开头时,会调用 AI 来响应用户消息 | `["请","傻妞"]` |
| `wakeUpKeyWords` | 当消息中包含唤醒关键词时,会进入 AI 唤醒状态 | `["召唤傻妞","打开傻妞"]` |
| `wakeUpKeywords` | 当消息中包含唤醒关键词时,会进入 AI 唤醒状态 | `["召唤傻妞","打开傻妞"]` |
| `exitKeywords` | 当消息中包含退出关键词时,会退出 AI 唤醒状态 | `["退出傻妞","关闭傻妞"]` |
| `onEnterAI` | 进入 AI 模式的欢迎语 | `["你好,我是傻妞,请问有什么能够帮你的吗?"]` |
| `onExitAI` | 退出 AI 模式的提示语 | `["傻妞已退出"]` |

View File

@ -48,12 +48,12 @@ export type AISpeakerConfig = SpeakerConfig & {
*
* //
*/
wakeUpKeyWords?: string[];
wakeUpKeywords?: string[];
/**
* 退
*
* 退退 AI
*
*
* /退/
*/
exitKeywords?: string[];
@ -91,7 +91,7 @@ export class AISpeaker extends Speaker {
onEnterAI: string[];
onExitAI: string[];
callAIPrefix: string[];
wakeUpKeyWords: string[];
wakeUpKeywords: string[];
exitKeywords: string[];
onAIAsking: string[];
onAIError: string[];
@ -104,7 +104,7 @@ export class AISpeaker extends Speaker {
askAI,
name = "傻妞",
switchSpeakerPrefix,
wakeUpKeyWords = ["打开", "进入", "召唤"],
wakeUpKeywords = ["打开", "进入", "召唤"],
exitKeywords = ["关闭", "退出", "再见"],
onAIAsking = ["让我先想想", "请稍等"],
onAIError = ["啊哦,出错了,请稍后再试吧!"],
@ -119,7 +119,7 @@ export class AISpeaker extends Speaker {
this.audio_error = audio_error;
this.switchSpeakerPrefix =
switchSpeakerPrefix ?? getDefaultSwitchSpeakerPrefix();
this.wakeUpKeyWords = wakeUpKeyWords.map((e) => e + this.name);
this.wakeUpKeywords = wakeUpKeywords.map((e) => e + this.name);
this.exitKeywords = exitKeywords.map((e) => e + this.name);
this.onEnterAI = config.onEnterAI ?? [
`你好,我是${this.name},很高兴为你服务!`,
@ -155,7 +155,7 @@ export class AISpeaker extends Speaker {
get commands() {
return [
{
match: (msg) => this.wakeUpKeyWords.some((e) => msg.text.includes(e)),
match: (msg) => this.wakeUpKeywords.some((e) => msg.text.includes(e)),
run: async (msg) => {
await this.enterKeepAlive();
},