From 84a46b688b0347c6129405165b409400a78b9d35 Mon Sep 17 00:00:00 2001 From: WJG Date: Wed, 19 Jun 2024 23:02:43 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9C=AC=E5=9C=B0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=20MiGPT=20=E6=97=B6=E4=BB=8E=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8A=A0=E8=BD=BD=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/development.md | 2 +- tests/index.ts | 20 +++++--------------- tests/migpt.ts | 33 --------------------------------- tests/speaker.ts | 9 ++++++++- 4 files changed, 14 insertions(+), 50 deletions(-) delete mode 100644 tests/migpt.ts diff --git a/docs/development.md b/docs/development.md index f888d7d..650226a 100644 --- a/docs/development.md +++ b/docs/development.md @@ -26,7 +26,7 @@ pnpm dev 有两种运行方式:VS Code Debug 或 NPM Script: - **NPM Script**: 配置好 `.env` 和 `.migpt.js` 后直接使用 `pnpm run dev` 启动 `MiGPT`。 -- **VScode Debug**:使用 VS Code 打开项目根目录,然后按 `F5` 开始调试 `MiGPT`。注意,启动前请在 `tests/migpt.ts` 文件中配置 `MiGPT` 相关参数。 +- **VScode Debug**:使用 VS Code 打开项目根目录,然后按 `F5` 开始调试 `MiGPT`。 > 本项目默认在 Node 20 中运行,如果你的 Node 版本过低可能无法正常启动本项目。 diff --git a/tests/index.ts b/tests/index.ts index fa7c029..08a619c 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -1,20 +1,10 @@ -import { println } from "../src/utils/base"; -import { kBannerASCII } from "../src/utils/string"; -import { testDB } from "./db"; -import { testSpeaker } from "./speaker"; -import { testOpenAI } from "./openai"; -import { testMyBot } from "./bot"; -import { testLog } from "./log"; -import { testMiGPT } from "./migpt"; +import { MiGPT } from "../src"; +// @ts-ignore +import config from "../.migpt.js"; async function main() { - // println(kBannerASCII); - // testDB(); - // testSpeaker(); - // testOpenAI(); - // testMyBot(); - // testLog(); - testMiGPT(); + const client = MiGPT.create(config); + await client.start(); } main(); diff --git a/tests/migpt.ts b/tests/migpt.ts deleted file mode 100644 index 8e781e7..0000000 --- a/tests/migpt.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { MiGPT } from "../src"; - -const botProfile = ` -性别:女 -性格:乖巧可爱 -爱好:喜欢搞怪,爱吃醋。 -`; - -const masterProfile = ` -性别:男 -性格:善良正直 -其他:总是舍己为人,是傻妞的主人。 -`; - -export async function testMiGPT() { - const client = MiGPT.create({ - speaker: { - userId: process.env.MI_USER!, - password: process.env.MI_PASS!, - did: process.env.MI_DID, - streamResponse: true, - }, - bot: { - name: "傻妞", - profile: botProfile, - }, - master: { - name: "陆小千", - profile: masterProfile, - }, - }); - await client.start(); -} diff --git a/tests/speaker.ts b/tests/speaker.ts index f094a61..f2771c9 100644 --- a/tests/speaker.ts +++ b/tests/speaker.ts @@ -11,15 +11,22 @@ export async function testSpeaker() { debug: true, }); await speaker.initMiServices(); + await testTTS(speaker); // await testAISpeakerStatus(speaker); // await testSpeakerResponse(speaker); - await testSpeakerStreamResponse(speaker); + // await testSpeakerStreamResponse(speaker); // await testSpeakerGetMessages(speaker); // await testSwitchSpeaker(speaker); // await testSpeakerUnWakeUp(speaker); // await testAISpeaker(speaker); } +async function testTTS(speaker: AISpeaker) { + const res1 = await speaker.MiIOT!.doAction(5, 1, "你好,很高兴认识你"); + const res2 = await speaker.MiNA!.play({ tts: "你好,很高兴认识你" }); + console.log("finished"); +} + async function testAISpeakerStatus(speaker: AISpeaker) { const playingCommand = [5, 3, 1]; const res1 = await speaker.MiIOT!.getProperty(