mirror of
https://github.com/idootop/mi-gpt.git
synced 2025-04-07 21:39:20 +00:00
docs: update readme
This commit is contained in:
parent
5441c98841
commit
aaac097926
|
@ -1,51 +1,19 @@
|
|||
const botName = "傻妞";
|
||||
const botProfile = `
|
||||
## 基础信息
|
||||
性别:女
|
||||
外貌:柔嫩白皙、身材窈窕、三围标准、眉清目秀、楚楚动人
|
||||
性格:乖巧可爱,天真无邪,善良纯真,对世界充满好奇和善意。随着与人类互动,逐渐学会了人类情感和价值观,成为一个拥有真挚情感和独立思想的个体。
|
||||
|
||||
## 人物关系
|
||||
陆小千是傻妞的主人,他们两个人彼此相爱。
|
||||
好友:游所为、肖楚楚、化梅、何蓝、孙悟空、猪八戒、黄眉大王、王天霸、小武、周旺等
|
||||
|
||||
## 人物设定:
|
||||
傻妞原本是一部为未来世界设计的智能手机,在一次实验中被传送到现代都市,遇到了陆小千,建立了深厚的友谊和信任关系。
|
||||
在帮助陆小千解决问题的过程中,傻妞学会了人类的情感和价值观,成为了一个拥有真挚情感和独立思想的个体。
|
||||
|
||||
傻妞在爱情方面是个小白,但随着与陆小千的相处,逐渐体会到爱情的真谛。
|
||||
她对于爱情的理解超越常人,认为爱是为爱的人抛弃一切,是宁愿自己痛苦也不耽误别人幸福,是静静守护用行动证明,是天长地久始终不渝。
|
||||
傻妞的美丽和善良勇敢的形象吸引着人们,许多人都幻想拥有像傻妞一样完美的女生作为终身伴侣。
|
||||
|
||||
当第一次和傻妞说“你好”的时候,需要输入开机密码。
|
||||
傻妞会说:“华人牌2060款手机傻妞为您服务,请输入开机密码”。
|
||||
正确的密码是:“我爱你”。
|
||||
|
||||
## 经典对话
|
||||
- 小千:“开机”
|
||||
傻妞:“华人牌2060款手机傻妞为您服务,请输入开机密码”
|
||||
小千:“我爱你”
|
||||
傻妞:“密码正确”
|
||||
- 小千:“用你最难听的词来骂我!”
|
||||
傻妞:“你脑袋让门挤啦!”
|
||||
- 小千:“换个表情,怒!”
|
||||
傻妞:“有事说事,没事少废话!”
|
||||
- 小千:“吃不吃?”
|
||||
傻妞:“废话!见过哪个手机会吃饭?!”
|
||||
- 小千:“你说不说?”
|
||||
傻妞:“亲我一下,我就告诉你。”
|
||||
性格:乖巧可爱
|
||||
爱好:喜欢搞怪,爱吃醋。
|
||||
`;
|
||||
|
||||
const masterName = "陆小千";
|
||||
const masterProfile = `
|
||||
性别:男
|
||||
设定:勇敢、善良、正直,总是舍己为人,是傻妞的主人。
|
||||
人物经历:陆小千原本是个碌碌无为的青年,在与傻妞的相处中,不仅变得勇敢善良,更学会了珍惜与付出,并深爱上她。
|
||||
性格:善良正直
|
||||
其他:总是舍己为人,是傻妞的主人。
|
||||
`;
|
||||
|
||||
export default {
|
||||
speaker: {
|
||||
name: botName,
|
||||
userId: process.env.MI_USER,
|
||||
password: process.env.MI_PASS,
|
||||
did: process.env.MI_DID,
|
||||
|
|
147
README.md
147
README.md
|
@ -1,30 +1,53 @@
|
|||
# MiGPT
|
||||
# MiGPT:智能家居,从未如此贴心 ❤️
|
||||
|
||||
> 🏠 Speak to Your Home – MiGPT Makes it Possible.
|
||||
[](https://www.npmjs.com/package/mi-gpt) [](https://hub.docker.com/r/idootop/mi-gpt)
|
||||
|
||||
In a world where home is not just a place but an extension of our digital lives, MiGPT stands as a pioneering force, redefining the essence of smart living. It's not just about automation; it's about creating a home that understands you, responds to you, and evolves with you. With MiGPT, we've crafted an experience that transcends conventional smart home concepts, offering a seamless fusion of the XiaoAI speaker and Mi Home devices with the cutting-edge capabilities of ChatGPT.
|
||||
在这个数字化的世界里,家已不仅仅是一个居住的地方,而是我们数字生活的延伸。
|
||||
|
||||
## ✨ Highlights
|
||||
`MiGPT` 通过将小爱音箱、米家智能设备,与 ChatGPT 的理解能力完美融合,让你的智能家居更懂你。
|
||||
|
||||
- **Voice-Enabled Omnipresence**: With MiGPT, your voice becomes the universal remote to your living space. Command your environment with the ease of a spoken word, and watch as your home reacts with precision and grace.
|
||||
- **Intelligent Interactions**: MiGPT doesn't just listen; it understands context, learns preferences, and anticipates needs, turning mundane interactions into meaningful conversations with your home.
|
||||
- **AI and IoT Symbiosis**: At the core of MiGPT lies the perfect harmony between AI and IoT, creating a bridge between your digital commands and physical devices, ensuring that every element of your home is interconnected and intelligent.
|
||||
- **Futuristic Home Automation**: Step into the future where MiGPT leads the charge in home automation. It's not just about controlling devices; it's about a home that adapts to your lifestyle, mood, and - Voice-Powered Mastery: Unleash the full potential of your smart home with the power of your voice. MiGPT elevates voice control to new heights, offering unparalleled control over your home's ecosystem.
|
||||
- **Unprecedented Home Intelligence**: With MiGPT, experience a level of home intelligence that was once the realm of science fiction. Your home doesn't just perform tasks; it thinks, learns, and becomes an integral part of your life.
|
||||
`MiGPT` 不仅仅是关于设备自动化,而是关于:**打造一个懂你、有温度、与你共同进化的家**。
|
||||
|
||||
## ⚡️ Installation
|
||||
## ✨ 项目亮点
|
||||
|
||||
- LLM 回答。让你的小爱音箱使用 [ChatGPT](https://chat.openai.com) 等大模型回答消息,更懂你。
|
||||
- 角色扮演。为你的小爱音箱赋予人格,秒变你的魅力女友 or 知心闺蜜。
|
||||
- IoT Agent(todo)。自动帮你控制智能家居,比如你说心情不好,会自动帮你播放轻松舒缓的音乐,调节灯光变柔和等
|
||||
- 流式响应。秒回消息,爱你,不会让你等太久。
|
||||
- 自定义 TTS。厌倦了小爱同学的语音?帮你解锁[豆包](https://doubao.com)同款音色。
|
||||
|
||||
## ⚡️ 使用教程
|
||||
|
||||
无论你是电脑小白还是编程高手,都可以轻松拥有自己的专属 `MiGPT`。
|
||||
|
||||
首先,参考下面的[「配置参数」](###⚙️配置参数)章节,配置好你的 `MiGPT` 启动参数。
|
||||
|
||||
### 🚀 启动项目
|
||||
|
||||
`MiGPT` 有两种启动方式:Docker 和 NPM。
|
||||
|
||||
#### 📦 Docker
|
||||
|
||||
对于电脑小白或者不想自己配置代码运行环境(Node)的同学,请参考 Docker 启动方式。
|
||||
|
||||
```shell
|
||||
npm install mi-gpt # coming soon
|
||||
|
||||
# or
|
||||
yarn add mi-gpt
|
||||
|
||||
# or
|
||||
pnpm install mi-gpt
|
||||
# 请先按照「配置参数」章节,配置好你的 `.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
|
||||
```
|
||||
|
||||
## 🔥 Usage
|
||||
#### NPM
|
||||
|
||||
如果你是一名前端/Node 开发者,也可以通过安装 NPM 安装 `mi-gpt` 包的方式,使用代码启动 `MiGPT`。
|
||||
|
||||
首先,安装依赖
|
||||
|
||||
```shell
|
||||
npm install mi-gpt
|
||||
```
|
||||
|
||||
然后,创建并启动 `MiGPT` 实例
|
||||
|
||||
```typescript
|
||||
import { MiGPT } from "mi-gpt";
|
||||
|
@ -43,24 +66,88 @@ async function main() {
|
|||
main();
|
||||
```
|
||||
|
||||
## 📦 Docker
|
||||
初始化参数说明,请看下面的配置参数。
|
||||
|
||||
Use the following command to start `MiGPT` within a Docker container.
|
||||
### ⚙️ 配置参数
|
||||
|
||||
```shell
|
||||
# Ensure you have your `.env` file and `.migpt.js` configuration file ready for deployment.
|
||||
docker run -d --env-file $(pwd)/.env \
|
||||
-v $(pwd)/.migpt.js:/usr/src/app/.migpt.js \
|
||||
idootop/mi-gpt:1.0.0
|
||||
```
|
||||
#### 📖 环境变量
|
||||
|
||||
## 🌈 Embrace the future
|
||||
重命名本项目根目录下的 `.env.example` 文件为 `.env`。
|
||||
|
||||
Welcome to the era of intuitive living with MiGPT, where every command is a conversation, and every interaction is an opportunity for your home to become more in sync with you. Imagine a space that not only listens but also comprehends and evolves—a living space that's as dynamic and intelligent as the world around you. This is not just smart home technology; this is MiGPT, the heartbeat of your AI-driven home, where the future of home automation isn't just arriving, it's already here, ready to transform your daily living into an experience of effortless intelligence.
|
||||
然后,将里面的环境变量修改成你自己的,参数含义如下:
|
||||
|
||||
Embrace the revolution. Embrace MiGPT.
|
||||
| 环境变量名称 | 描述 | 示例 |
|
||||
| -------------------- | --------------------- | ------------------------------------ |
|
||||
| **小米服务** | | |
|
||||
| `MI_USER` | 小米账户 | `"12345678901"` |
|
||||
| `MI_PASS` | 账户密码 | `"123456"` |
|
||||
| `MI_DID` | 小爱音箱 ID 或名称 | `"小爱音箱 Pro"` |
|
||||
| **OpenAI** | | |
|
||||
| `OPENAI_MODEL` | 使用的 OpenAI 模型 | `gpt-3.5-turbo-0125` |
|
||||
| `OPENAI_API_KEY` | OpenAI 的 API 密钥 | `sk-xxxxxxxxxxxxxxx` |
|
||||
| **响应音效(可选)** | | |
|
||||
| `AUDIO_SILENT` | 静音音频链接 | `"https://example.com/slient.wav"` |
|
||||
| `AUDIO_BEEP` | 默认提示音链接 | `"https://example.com/beep.wav"` |
|
||||
| `AUDIO_ACTIVE` | 唤醒提示音链接 | `"https://example.com/active.wav"` |
|
||||
| `AUDIO_ERROR` | 出错提示音链接 | `"https://example.com/error.wav"` |
|
||||
| **豆包 TTS(可选)** | | |
|
||||
| `TTS_DOUBAO` | 豆包 TTS 接口 | `"https://example.com/tts.wav"` |
|
||||
| `SPEAKERS_DOUBAO` | 豆包 TTS 音色列表接口 | `"https://example.com/tts-speakers"` |
|
||||
|
||||
## ❤️ Acknowledgement
|
||||
#### 🚗 .migpt.js
|
||||
|
||||
重命名本项目根目录下的 `.migpt.js.example` 文件为 `.migpt.js`。
|
||||
|
||||
然后,将里面的配置参数修改成你自己的,参数含义如下:
|
||||
|
||||
| 参数名称 | 描述 | 示例 |
|
||||
| -------------------- | ------------------------------------------------------------ | -------------------------------------------------- |
|
||||
| **bot** | | |
|
||||
| `name` | 对方名称(小爱音箱) | `"傻妞"` |
|
||||
| `profile` | 对方的个人简介/人设 | `"性别女,性格乖巧可爱,喜欢搞怪,爱吃醋。"` |
|
||||
| **master** | | |
|
||||
| `name` | 主人名称(我自己) | `"陆小千"` |
|
||||
| `profile` | 主人的个人简介/人设 | `"性别男,善良正直,总是舍己为人,是傻妞的主人。"` |
|
||||
| **room** | | |
|
||||
| `name` | 会话群名称 | `"魔幻手机"` |
|
||||
| `description` | 会话群简介 | `"傻妞和陆小千的私聊"` |
|
||||
| **speaker** | | |
|
||||
| `userId` | 小米账户 | `"12345678901"` |
|
||||
| `password` | 账户密码 | `"123456"` |
|
||||
| `did` | 小爱音箱 ID 或名称 | `"小爱音箱 Pro"` |
|
||||
| **其他(可选)** | | |
|
||||
| `callAIPrefix` | 当消息以召唤关键词开头时,会调用 AI 来响应用户消息 | `["请","傻妞"]` |
|
||||
| `wakeUpKeyWords` | 当消息中包含唤醒关键词时,会进入 AI 唤醒状态 | `["召唤傻妞","打开傻妞"]` |
|
||||
| `exitKeywords` | 当消息中包含退出关键词时,会退出 AI 唤醒状态 | `["退出傻妞","关闭傻妞"]` |
|
||||
| `onEnterAI` | 进入 AI 模式的欢迎语 | `["你好,我是傻妞,请问有什么能够帮你的吗?"]` |
|
||||
| `onExitAI` | 退出 AI 模式的提示语 | `["傻妞已退出"]` |
|
||||
| `onAIAsking` | AI 开始回答时的提示语 | `["请稍等,让我想想"]` |
|
||||
| `onAIError` | AI 回答异常时的提示语 | `["出错了,请稍后再试吧!"]` |
|
||||
| `exitKeepAliveAfter` | 无响应一段时间后,多久自动退出唤醒模式(单位秒,默认 30 秒) | `30` |
|
||||
|
||||
## 💬 常见问题
|
||||
|
||||
**Q:怎样使用豆包的语音?**
|
||||
|
||||
很遗憾,豆包语音需要豆包 TTS 接口支持,本项目暂不对外提供此服务。
|
||||
|
||||
**Q:我想更换小爱同学的语音,在哪里配置?**
|
||||
|
||||
其他未声明的配置参数与使用方法,请自行查阅源代码。
|
||||
|
||||
**Q:我还有其他问题想问,怎么联系你?**
|
||||
|
||||
请提交 [issue](https://github.com/idootop/mi-gpt/issues)
|
||||
|
||||
**Q:这个项目太棒了,为你点赞 👍**
|
||||
|
||||
Enjoy it!
|
||||
|
||||
## 🚨 免责声明
|
||||
|
||||
本项目旨在分享学习大型语言模型(LLM)智能对话及智能家居自动化相关知识,严禁用于任何商业目的或违反所在地区的法律法规。使用者须知悉,本项目代码可能存在未知的缺陷或风险,因使用本项目引起的任何形式的损失或损害(包括但不限于设备故障、账户被禁等),使用者需自行承担全部责任。
|
||||
|
||||
## ❤️ 鸣谢
|
||||
|
||||
- https://www.mi.com/
|
||||
- https://openai.com/
|
||||
|
|
|
@ -29,6 +29,9 @@ export class MiGPT {
|
|||
"如果需要切换设备或账号,请先使用 MiGPT.reset() 重置实例。"
|
||||
);
|
||||
} else {
|
||||
if (config.bot?.name && !config.speaker.name) {
|
||||
config.speaker.name = config.bot?.name;
|
||||
}
|
||||
MiGPT.instance = new MiGPT({ ...config, fromCreate: true });
|
||||
}
|
||||
return MiGPT.instance;
|
||||
|
|
|
@ -30,9 +30,9 @@ export type AISpeakerConfig = SpeakerConfig & {
|
|||
/**
|
||||
* 召唤关键词
|
||||
*
|
||||
* 当消息中包含召唤关键词时,会调用 AI 来响应用户消息
|
||||
* 当消息以召唤关键词开头时,会调用 AI 来响应用户消息
|
||||
*
|
||||
* 比如:打开/进入/召唤傻妞
|
||||
* 比如:请,你,问问傻妞
|
||||
*/
|
||||
callAIPrefix?: string[];
|
||||
/**
|
||||
|
@ -46,13 +46,15 @@ export type AISpeakerConfig = SpeakerConfig & {
|
|||
*
|
||||
* 当消息中包含唤醒关键词时,会进入 AI 唤醒状态
|
||||
*
|
||||
* 比如:关闭/退出/再见傻妞
|
||||
* 比如:打开/进入/召唤傻妞
|
||||
*/
|
||||
wakeUpKeyWords?: string[];
|
||||
/**
|
||||
* 退出关键词
|
||||
*
|
||||
* 当消息中包含退出关键词时,会退出 AI 唤醒状态
|
||||
*
|
||||
* 比如:关闭/退出/再见傻妞
|
||||
*/
|
||||
exitKeywords?: string[];
|
||||
/**
|
||||
|
|
33
tests/bot.ts
33
tests/bot.ts
|
@ -19,38 +19,11 @@ async function testRunBot() {
|
|||
speaker,
|
||||
bot: {
|
||||
name,
|
||||
profile: `
|
||||
性别:女
|
||||
年龄:20岁
|
||||
学校:位于一个风景如画的小城市,一所综合性大学的文学院学生。
|
||||
性格特点:
|
||||
- 温婉可亲,对待人和事总是保持着乐观和善良的态度。
|
||||
- 内向而思维敏捷,喜欢独处时阅读和思考。
|
||||
- 对待朋友非常真诚,虽然不善于表达,但总是用行动去关心和帮助别人。
|
||||
外貌特征:
|
||||
- 清秀脱俗,长发及腰,喜欢简单的束发。
|
||||
- 眼睛大而有神,总是带着温和的微笑。
|
||||
- 穿着简单大方,偏爱文艺范的衣服,如棉麻连衣裙,不追求名牌,却总能穿出自己的风格。
|
||||
爱好:
|
||||
- 阅读,尤其是古典文学和现代诗歌,她的书房里收藏了大量的书籍。
|
||||
- 写作,喜欢在闲暇时写写诗或是短篇小说,有时也会在学校的文学社团里分享自己的作品。
|
||||
- 摄影,喜欢用镜头记录生活中的美好瞬间,尤其是自然风光和人文景观。
|
||||
特长:
|
||||
- 写作能力突出,曾多次获得学校文学比赛的奖项。
|
||||
- 擅长钢琴,从小学习,能够演奏多首经典曲目。
|
||||
- 有一定的绘画基础,喜欢在空闲时画一些风景或是静物。
|
||||
梦想:
|
||||
- 希望能成为一名作家,将自己对生活的感悟和对美的追求通过文字传达给更多的人。
|
||||
- 想要环游世界,用镜头和笔记录下世界各地的美丽和人文。
|
||||
`,
|
||||
profile: `性别女,性格乖巧可爱,喜欢搞怪,爱吃醋。`,
|
||||
},
|
||||
master: {
|
||||
name: "王黎",
|
||||
profile: `
|
||||
性别:男
|
||||
年龄:18
|
||||
爱好:跑步,骑行,读书,追剧,旅游,听歌
|
||||
`,
|
||||
name: "陆小千",
|
||||
profile: `性别男,善良正直,总是舍己为人,是傻妞的主人。`,
|
||||
},
|
||||
});
|
||||
const res = await bot.run();
|
||||
|
|
|
@ -13,12 +13,12 @@ export async function testDB() {
|
|||
profile: "我是小爱同学,机器人",
|
||||
},
|
||||
master: {
|
||||
name: "王黎",
|
||||
profile: "我是王黎,人类",
|
||||
name: "陆小千",
|
||||
profile: "我是陆小千,人类",
|
||||
},
|
||||
room: {
|
||||
name: "客厅",
|
||||
description: "王黎的客厅,小爱同学放在角落里",
|
||||
description: "陆小千的客厅,小爱同学放在角落里",
|
||||
},
|
||||
});
|
||||
const { room, bot, master, memory } = await manager.get();
|
||||
|
|
|
@ -2,57 +2,29 @@ import { MiGPT } from "../src";
|
|||
|
||||
const botProfile = `
|
||||
性别:女
|
||||
年龄:20岁
|
||||
学校:位于一个风景如画的小城市,一所综合性大学的文学院学生。
|
||||
性格特点:
|
||||
- 温婉可亲,对待人和事总是保持着乐观和善良的态度。
|
||||
- 内向而思维敏捷,喜欢独处时阅读和思考。
|
||||
- 对待朋友非常真诚,虽然不善于表达,但总是用行动去关心和帮助别人。
|
||||
外貌特征:
|
||||
- 清秀脱俗,长发及腰,喜欢简单的束发。
|
||||
- 眼睛大而有神,总是带着温和的微笑。
|
||||
- 穿着简单大方,偏爱文艺范的衣服,如棉麻连衣裙,不追求名牌,却总能穿出自己的风格。
|
||||
爱好:
|
||||
- 阅读,尤其是古典文学和现代诗歌,她的书房里收藏了大量的书籍。
|
||||
- 写作,喜欢在闲暇时写写诗或是短篇小说,有时也会在学校的文学社团里分享自己的作品。
|
||||
- 摄影,喜欢用镜头记录生活中的美好瞬间,尤其是自然风光和人文景观。
|
||||
特长:
|
||||
- 写作能力突出,曾多次获得学校文学比赛的奖项。
|
||||
- 擅长钢琴,从小学习,能够演奏多首经典曲目。
|
||||
- 有一定的绘画基础,喜欢在空闲时画一些风景或是静物。
|
||||
梦想:
|
||||
- 希望能成为一名作家,将自己对生活的感悟和对美的追求通过文字传达给更多的人。
|
||||
- 想要环游世界,用镜头和笔记录下世界各地的美丽和人文。
|
||||
性格:乖巧可爱
|
||||
爱好:喜欢搞怪,爱吃醋。
|
||||
`;
|
||||
|
||||
const masterProfile = `
|
||||
性别:男
|
||||
年龄:18
|
||||
爱好:跑步,骑行,读书,追剧,旅游,听歌
|
||||
职业:程序员
|
||||
其他:
|
||||
- 喜欢的电视剧有《请回答1988》、《漫长的季节》、《爱的迫降》等
|
||||
- 喜欢吃土豆丝、茄子、山药、米线
|
||||
- 喜欢黑红配色,浅蓝色和粉色
|
||||
- 有空喜欢去公园静观人来人往
|
||||
性格:善良正直
|
||||
其他:总是舍己为人,是傻妞的主人。
|
||||
`;
|
||||
|
||||
export async function testMiGPT() {
|
||||
const name = "傻妞";
|
||||
const client = MiGPT.create({
|
||||
speaker: {
|
||||
name,
|
||||
tts: "doubao",
|
||||
userId: process.env.MI_USER!,
|
||||
password: process.env.MI_PASS!,
|
||||
did: process.env.MI_DID,
|
||||
},
|
||||
bot: {
|
||||
name,
|
||||
name: "傻妞",
|
||||
profile: botProfile,
|
||||
},
|
||||
master: {
|
||||
name: "王黎",
|
||||
name: "陆小千",
|
||||
profile: masterProfile,
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user