chore: 本地测试 MiGPT 时从配置文件加载参数

This commit is contained in:
WJG 2024-06-19 23:02:43 +08:00
parent 02114694ea
commit 84a46b688b
No known key found for this signature in database
GPG Key ID: 258474EF8590014A
4 changed files with 14 additions and 50 deletions

View File

@ -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 版本过低可能无法正常启动本项目。

View File

@ -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();

View File

@ -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();
}

View File

@ -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(