Skip to content

Commit

Permalink
Merge pull request #178 from idootop/dev
Browse files Browse the repository at this point in the history
release: v4.2.0
  • Loading branch information
idootop committed Aug 26, 2024
2 parents 5d455e2 + a1b0481 commit 9f83eb1
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 327 deletions.
4 changes: 2 additions & 2 deletions .migpt.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default {
*/

// 是否启用连续对话功能,部分小爱音箱型号无法查询到正确的播放状态,需要关闭连续对话
streamResponse: true,
streamResponse: false,
// 连续对话时,无响应多久后自动退出
exitKeepAliveAfter: 30, // 默认 30 秒,建议不要超过 1 分钟
// 连续对话时,下发 TTS 指令多长时间后开始检测设备播放状态(默认 3 秒)
Expand All @@ -164,6 +164,6 @@ export default {
// 是否跟踪 Mi Service 相关日志(打开后可以查看设备 did)
enableTrace: false, // 一般情况下不要打开
// 网络请求超时时长(单位毫秒,默认 5 秒)
timeout: 5000,
timeout: 5000,
},
};
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

[![npm version](https://badge.fury.io/js/mi-gpt.svg)](https://www.npmjs.com/package/mi-gpt) [![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)

<video src='https://github.com/idootop/mi-gpt/assets/35302658/dc336916-9087-418b-bc1b-04d5534dce8f'></video>

> 👉 查看完整演示视频:【[整活!将小爱音箱接入 ChatGPT 和豆包,改造成你的专属语音助手~](https://www.bilibili.com/video/BV1N1421y7qn/?share_source=copy_web&vd_source=5d4e78ff2a0dc6a661baa65f479199c1)
<video src='https://github.com/idootop/mi-gpt/assets/35302658/dc336916-9087-418b-bc1b-04d5534dce8f'></video>

## 👋 项目简介

在这个数字化的世界里,家已不仅仅是一个居住的地方,而是我们数字生活的延伸。
Expand All @@ -29,7 +29,7 @@
- **💬 流式响应**。爱情来得太快就像龙卷风,而你的小爱音箱也是,对你的爱意秒回,爱你不会让你等太久。
- **🧠 长短期记忆**。小爱音箱现在能记住你们之间的每一次对话,越聊越默契,就像是你身边的老朋友。
- **🔊 自定义 TTS**。厌倦了小爱同学的语音?帮你解锁[「豆包」](https://doubao.com)同款音色,就像真人在回你的消息。
- **🤖️ 智能家居 Agent**。心情不好?小爱立刻懂你,自动帮你播放喜欢的音乐,调节灯光,逗你开心。_TODO_
- ~**🤖️ 智能家居 Agent**。心情不好?小爱立刻懂你,自动帮你播放喜欢的音乐,调节灯光,逗你开心。~

## 🦄 Sponsors

Expand All @@ -39,15 +39,9 @@
## ⚡️ 快速开始

> 查看视频教程 👉 【[MiGPT 光速入门教程,从零教你调教小爱音箱~](https://www.bilibili.com/video/BV1zb421H7cS)
`MiGPT` 有两种启动方式: [Docker](#docker)[Node.js](#nodejs)

启动成功后,你可以通过以下方式来召唤 AI 回答问题:
### 视频教程

- **小爱同学,请 xxx**。比如 `小爱同学,请问地球为什么是圆的?`
- **小爱同学,你 xxx**。比如 `小爱同学,你喜欢我吗?`
- **小爱同学,召唤 xxx**。比如 `小爱同学,召唤傻妞`
👉 [MiGPT 光速入门视频教程,手把手教你调教小爱音箱~](https://www.bilibili.com/video/BV1zb421H7cS)

### 设备要求

Expand All @@ -57,6 +51,16 @@

> 注意:本项目暂不支持小度音箱、天猫精灵、HomePod 等智能音箱设备,亦无相关适配计划。
### 使用方式

`MiGPT` 有两种启动方式: [Docker](#docker)[Node.js](#nodejs)

启动成功后,你可以通过以下方式来召唤 AI 回答问题:

- **小爱同学,请 xxx**。比如 `小爱同学,请问地球为什么是圆的?`
- **小爱同学,你 xxx**。比如 `小爱同学,你喜欢我吗?`
- **小爱同学,召唤 xxx**。比如 `小爱同学,召唤傻妞`

### 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)
Expand Down Expand Up @@ -104,7 +108,7 @@ main();

## 📖 使用文档

以下为更详细的使用教程,大多数问题都可在 [💬 常见问题](https://github.com/idootop/mi-gpt/blob/main/docs/faq.md) 中找到答案。
提示:大多数问题都可在 [💬 常见问题](https://github.com/idootop/mi-gpt/blob/main/docs/faq.md) 中找到答案。

- [🔥 官方视频教程](https://www.bilibili.com/video/BV1zb421H7cS)
- [⚙️ 参数设置](https://github.com/idootop/mi-gpt/blob/main/docs/settings.md)
Expand All @@ -116,14 +120,14 @@ main();
- [✨ 更新日志](https://github.com/idootop/mi-gpt/blob/main/docs/changelog.md)
- [🚀 Roadmap](https://github.com/idootop/mi-gpt/blob/main/docs/roadmap.md)

## 👍 推荐项目与教程
## 🤩 推荐项目与教程

| 项目链接 | 简介 | 来源 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| **相关项目** | | |
| [@shinedlc/mi-gpt](https://github.com/shinedlc/mi-gpt) | 一个接入了摄像头硬件 + 本机搭建 Ollama 模型的 MiGPT 分支,让小爱同学可以看到和理解现实世界 | @shinedlc |
| [@lmk123/migpt-cli](https://github.com/lmk123/migpt-cli) | 通过图形化界面的方式创建并管理 MiGPT,支持运行多个账号。 | @lmk123 |
| [@lmk123/migpt-cli/gui](https://migptgui.com/gui/) | 直接在网页上更方便的编辑和生成 `.migpt.js``.env` 配置文件 | @lmk123 |
| [MiGPT GUI](https://migptgui.com/) | 通过图形化界面的方式创建并管理 MiGPT,支持运行多个账号 | @lmk123 |
| - | 直接在网页上更方便的编辑和生成 `.migpt.js``.env` 配置文件 | @lmk123 |
| [@shinedlc/mi-gpt](https://github.com/shinedlc/mi-gpt) | 支持摄像头模块的 MiGPT 分支,让小爱同学可以看到和理解现实世界 | @shinedlc |
| **使用教程** | | |
| [MiGPT 官方视频教程](https://www.bilibili.com/video/BV1zb421H7cS) | 官方视频教程配套 PPT 文件 👉 [MiGPT 官方教程.pdf](https://github.com/idootop/mi-gpt/blob/main/assets/pdf/MiGPT%E5%AE%98%E6%96%B9%E6%95%99%E7%A8%8B.pdf) | @idootop |
| [MiGPT 接入豆包等大模型教程](https://migptgui.com/docs/apply/) | 豆包、Moonshot(Kimi)等常见大模型的详细接入教程 | @lmk123 |
Expand Down
16 changes: 16 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# ✨ 更新日志

## v4.2.0

### ✨ 新功能

- ✅ 新增对小爱音箱 LLM 消息的支持

### 🐛 修复

- ✅ 修复 LLM 返回值格式与预期不符的问题 by @yanyao2333

### ❤️ 感谢

- @yanyao2333 让 LLM 返回值的解析更加健壮 https://github.com/idootop/mi-gpt/pull/160
- @LyCecilion 对小爱音箱丢消息问题的详细反馈 https://github.com/idootop/mi-gpt/issues/177
- @Jasonzhu1207 在 telegram 群中帮忙解答问题

## v4.1.0

### 🐛 修复
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mi-gpt",
"version": "4.1.0",
"version": "4.2.0",
"type": "module",
"description": "将小爱音箱接入 ChatGPT 和豆包,改造成你的专属语音助手。",
"homepage": "https://github.com/idootop/mi-gpt",
Expand All @@ -25,16 +25,17 @@
"scripts": {
"start": "node ./app.js",
"dev": "node --env-file=.env ./app.js",
"build": "npx -y prisma generate && tsup",
"build": "npx -y prisma generate && rm -rf dist && tsup",
"db:gen": "npx -y prisma migrate dev --name init",
"db:reset": "rm -f .mi.json .bot.json prisma/app.db prisma/app.db-journal",
"prepublish": "npm run build",
"postinstall": "npx -y prisma migrate dev --name hello"
},
"dependencies": {
"@prisma/client": "^5.14.0",
"fs-extra": "^11.2.0",
"mi-service-lite": "^3.0.0",
"openai": "^4.52.2",
"mi-service-lite": "^3.1.0",
"openai": "^4.56.0",
"prisma": "^5.14.0",
"proxy-agent": "^6.4.0"
},
Expand Down
40 changes: 19 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/services/speaker/speaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class Speaker extends BaseSpeaker {
private async _fetchFirstMessage() {
const msgs = await this.getMessages({
limit: 1,
filterTTS: false,
filterAnswer: false,
});
this.currentQueryMsg = msgs[0];
}
Expand Down Expand Up @@ -285,23 +285,26 @@ export class Speaker extends BaseSpeaker {
async getMessages(options?: {
limit?: number;
timestamp?: number;
filterTTS?: boolean;
filterAnswer?: boolean;
}): Promise<QueryMessage[]> {
const filterTTS = options?.filterTTS ?? true;
const filterAnswer = options?.filterAnswer ?? true;
const conversation = await this.MiNA!.getConversations(options);
this._lastConversation = conversation;
let records = conversation?.records ?? [];
if (filterTTS) {
if (filterAnswer) {
// 过滤有小爱回答的消息
records = records.filter(
(e) => e.answers.length > 0 && e.answers.some((e) => e.type === "TTS")
(e) =>
["TTS", "LLM"].includes(e.answers[0]?.type) && // 过滤 TTS 和 LLM 消息
e.answers.length === 1 // 播放音乐时会有 TTS、Audio 两个 Answer
);
}
return records.map((e) => {
const ttsAnswer = e.answers.find((e) => e.type === "TTS") as any;
const msg: any = e.answers[0];
const answer = msg?.tts?.text?.trim() ?? msg?.llm?.text?.trim();
return {
answer,
text: e.query,
answer: ttsAnswer?.tts?.text?.trim(),
timestamp: e.time,
};
});
Expand Down
51 changes: 0 additions & 51 deletions tests/bot.ts

This file was deleted.

Loading

0 comments on commit 9f83eb1

Please sign in to comment.