mirror of
https://github.com/idootop/mi-gpt.git
synced 2025-04-13 16:47:09 +00:00
chore: 本地测试 MiGPT 时从配置文件加载参数
This commit is contained in:
parent
02114694ea
commit
84a46b688b
|
@ -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 版本过低可能无法正常启动本项目。
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue
Block a user