diff --git a/README.md b/README.md index bfba1bc..9af68e8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ - **💬 流式响应**。爱情来得太快就像龙卷风,而你的小爱音箱也是,对你的爱意秒回,爱你不会让你等太久。 - **🧠 长短期记忆**。小爱音箱现在能记住你们之间的每一次对话,越聊越默契,就像是你身边的老朋友。 - **🔊 自定义 TTS**。厌倦了小爱同学的语音?帮你解锁[「豆包」](https://doubao.com)同款音色,就像真人在回你的消息。 -- **🤖️ 智能家居 Agent**。心情不好?小爱立刻懂你,自动帮你播放喜欢的音乐,调节灯光,逗你开心。*TODO* +- **🤖️ 智能家居 Agent**。心情不好?小爱立刻懂你,自动帮你播放喜欢的音乐,调节灯光,逗你开心。_TODO_ ## ⚡️ 使用教程 @@ -27,6 +27,8 @@ #### 📦 Docker +[![Docker Image Version](https://img.shields.io/docker/v/idootop/mi-gpt?color=%23086DCD&label=docker%20image)](https://hub.docker.com/r/idootop/mi-gpt) + 对于电脑小白或者不想自己配置代码运行环境(Node)的同学,可以使用 Docker 启动方式。 请先按照[「配置参数」](#%EF%B8%8F-配置参数)章节,配置好你的 `.env` 和 `.migpt.js` 文件。然后使用以下命令启动 docker: @@ -39,6 +41,8 @@ docker run -d --env-file $(pwd)/.env \ #### ⭐️ NPM +[![npm version](https://badge.fury.io/js/mi-gpt.svg)](https://www.npmjs.com/package/mi-gpt) + 如果你是一名前端 (Node) 开发者,也可以通过 NPM 安装 `mi-gpt` 包的方式,使用代码启动 `MiGPT`。 ```shell diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 7780761..0000000 --- a/TODO.md +++ /dev/null @@ -1,8 +0,0 @@ -- ✅ Auto mute XiaoAi reply (not perfect yet) -- ✅ Stream response -- ✅ Deactivate Xiaoai -- ✅ Update long/short memories -- ✅ Logger -- ✅ Npm export -- ✅ 更新人设:你是[xxx]你[xxx] -- Docker diff --git a/package.json b/package.json index 3e9b32e..f6a5c13 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "axios": "^1.6.5", "fs-extra": "^11.2.0", "https-proxy-agent": "^7.0.4", - "mi-service-lite": "^2.2.0", + "mi-service-lite": "^2.3.0", "openai": "^4.28.0", "prisma": "^5.8.1" }, diff --git a/src/services/bot/index.ts b/src/services/bot/index.ts index 75bb0a6..aa7c894 100644 --- a/src/services/bot/index.ts +++ b/src/services/bot/index.ts @@ -93,7 +93,7 @@ export class MyBot { if (config) { this.speaker.name = config?.bot.name; await this.speaker.response({ - text: `我是${name},很高兴认识你!`, + text: `你好,我是${name},很高兴认识你!`, keepAlive: this.speaker.keepAlive, }); } else { diff --git a/src/services/speaker/ai.ts b/src/services/speaker/ai.ts index f39a115..5f74a01 100644 --- a/src/services/speaker/ai.ts +++ b/src/services/speaker/ai.ts @@ -88,11 +88,11 @@ export class AISpeaker extends Speaker { askAI: AISpeakerConfig["askAI"]; name: string; switchSpeakerPrefix: string[]; - onEnterAI: string[]; - onExitAI: string[]; - callAIPrefix: string[]; - wakeUpKeywords: string[]; - exitKeywords: string[]; + onEnterAI: () => string[]; + onExitAI: () => string[]; + callAIPrefix: () => string[]; + wakeUpKeywords: () => string[]; + exitKeywords: () => string[]; onAIAsking: string[]; onAIError: string[]; audio_active?: string; @@ -119,23 +119,18 @@ export class AISpeaker extends Speaker { this.audio_error = audio_error; this.switchSpeakerPrefix = switchSpeakerPrefix ?? getDefaultSwitchSpeakerPrefix(); - this.wakeUpKeywords = wakeUpKeywords.map((e) => e + this.name); - this.exitKeywords = exitKeywords.map((e) => e + this.name); - this.onEnterAI = config.onEnterAI ?? [ - `你好,我是${this.name},很高兴为你服务!`, - ]; - this.onExitAI = config.onExitAI ?? [`${this.name}已关闭!`]; - this.callAIPrefix = config.callAIPrefix ?? [ - "请", - "你", - this.name, - "问问" + this.name, - ]; + this.wakeUpKeywords = () => wakeUpKeywords.map((e) => e + this.name); + this.exitKeywords = () => exitKeywords.map((e) => e + this.name); + this.onEnterAI = () => + config.onEnterAI ?? [`你好,我是${this.name},很高兴为你服务!`]; + this.onExitAI = () => config.onExitAI ?? [`${this.name}已关闭!`]; + this.callAIPrefix = () => + config.callAIPrefix ?? ["请", "你", this.name, "问问" + this.name]; } async enterKeepAlive() { // 回应 - await this.response({ text: pickOne(this.onEnterAI)!, keepAlive: true }); + await this.response({ text: pickOne(this.onEnterAI())!, keepAlive: true }); // 唤醒 await super.enterKeepAlive(); } @@ -145,7 +140,7 @@ export class AISpeaker extends Speaker { await super.exitKeepAlive(); // 回应 await this.response({ - text: pickOne(this.onExitAI)!, + text: pickOne(this.onExitAI())!, keepAlive: false, playSFX: false, }); @@ -155,13 +150,13 @@ 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(); }, }, { - match: (msg) => this.exitKeywords.some((e) => msg.text.includes(e)), + match: (msg) => this.exitKeywords().some((e) => msg.text.includes(e)), run: async (msg) => { await this.exitKeepAlive(); }, @@ -188,7 +183,7 @@ export class AISpeaker extends Speaker { { match: (msg) => this.keepAlive || - this.callAIPrefix.some((e) => msg.text.startsWith(e)), + this.callAIPrefix().some((e) => msg.text.startsWith(e)), run: (msg) => this.askAIForAnswer(msg), }, ] as SpeakerCommand[]; diff --git a/src/utils/string.ts b/src/utils/string.ts index b14adad..701e108 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -6,14 +6,14 @@ export const kAreYouOK = "¿ʞо ∩оʎ ǝɹɐ"; // are you ok? export const kBannerASCII = ` -/$$ /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$$ +/ $$ /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$$$ | $$$ /$$$|__/ /$$__ $$| $$__ $$|__ $$__/ -| $$$$ /$$$$ /$$| $$ \__/| $$ \ $$ | $$ +| $$$$ /$$$$ /$$| $$ \\__/| $$ \\ $$ | $$ | $$ $$/$$ $$| $$| $$ /$$$$| $$$$$$$/ | $$ | $$ $$$| $$| $$| $$|_ $$| $$____/ | $$ -| $$\ $ | $$| $$| $$ \ $$| $$ | $$ -| $$ \/ | $$| $$| $$$$$$/| $$ | $$ -|__/ |__/|__/ \______/ |__/ |__/ +| $$\\ $ | $$| $$| $$ \\ $$| $$ | $$ +| $$ \\/ | $$| $$| $$$$$$/| $$ | $$ +|__/ |__/|__/ \\______/ |__/ |__/ MiGPT v1.0.0 by: del-wang.eth diff --git a/yarn.lock b/yarn.lock index d6b90c9..699847e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -927,10 +927,10 @@ merge2@^1.3.0, merge2@^1.4.1: resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -mi-service-lite@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/mi-service-lite/-/mi-service-lite-2.2.0.tgz#30bcebaa8faeb83d1606be0c2ef552a4621dc722" - integrity sha512-rcepSHGA4yUOjI9Tim/1kgu6BzMGeblMl+Nm5aevlRoXw7vv/x8fGx3jiwMV+LX6aDyY7NABEBbjwdPc98wlGA== +mi-service-lite@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/mi-service-lite/-/mi-service-lite-2.3.0.tgz#cb24477e37b674d9f758790c9f8fbb3637de1753" + integrity sha512-a9r5quQjwGRz7aE7oOjLAJfgwp0E6nKpP2c/ZYbl6jYKsvz05f/e8bPGY73dDtCtQHGTONxPZjeoGraQbQLJZg== dependencies: axios "^1.6.5" pako "^2.1.0"