From 6041088fbcad424aceeb8671d9223e960fb04328 Mon Sep 17 00:00:00 2001 From: WJG Date: Tue, 11 Jun 2024 20:33:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E9=9F=B3=E9=93=BE=E6=8E=A5=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=B0=8F=E7=88=B1=E5=9B=9E=E7=AD=94=E5=AE=8C=E6=AF=95=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=BB=8D=E7=84=B6=E9=87=8D=E5=A4=8D=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E6=96=87=E5=AD=97=E6=8F=90=E7=A4=BA=E8=AF=AD=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/speaker/ai.ts | 7 ++++++- tests/openai.ts | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/services/speaker/ai.ts b/src/services/speaker/ai.ts index 9104697..cc2e07f 100644 --- a/src/services/speaker/ai.ts +++ b/src/services/speaker/ai.ts @@ -225,7 +225,12 @@ export class AISpeaker extends Speaker { } }, async (msg, data) => { - if (data.answer && data.res == null && this.streamResponse) { + if ( + data.answer && + data.res == null && + !this.audioBeep && + this.streamResponse + ) { // 回复完毕 await this.response({ text: pickOne(this.onAIReplied)!, diff --git a/tests/openai.ts b/tests/openai.ts index b6f4756..6fb4319 100644 --- a/tests/openai.ts +++ b/tests/openai.ts @@ -2,7 +2,13 @@ import { randomUUID } from "crypto"; import { openai } from "../src/services/openai"; export async function testOpenAI() { - await testStreamChat(); + await testChat(); + // await testStreamChat(); +} + +async function testChat() { + const res = await openai.chat({ user: "地球为什么是圆的?" }); + console.log("\nFinal result:\n", res?.content); } async function testStreamChat() {