From b12a437a3040685b833d34b275492412f03ad3ec Mon Sep 17 00:00:00 2001 From: balibabu Date: Sat, 14 Sep 2024 15:58:02 +0800 Subject: [PATCH] feat: Supports text output and sound output #1877 (#2436) ### What problem does this PR solve? feat: Supports text output and sound output #1877 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/.umirc.ts | 7 ------- web/src/components/message-item/hooks.ts | 17 +++++++++-------- web/src/locales/en.ts | 6 +++--- .../assistant-setting.tsx | 4 ++-- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/web/.umirc.ts b/web/.umirc.ts index e569a3ad..bcdae7c7 100644 --- a/web/.umirc.ts +++ b/web/.umirc.ts @@ -36,12 +36,5 @@ export default defineConfig({ logger: console, // pathRewrite: { '^/v1': '/v1' }, }, - '/HPImageArchive': { - target: 'https://cn.bing.com/', - changeOrigin: true, - ws: true, - logger: console, - // pathRewrite: { '^/v1': '/v1' }, - }, }, }); diff --git a/web/src/components/message-item/hooks.ts b/web/src/components/message-item/hooks.ts index adaab088..7760bab4 100644 --- a/web/src/components/message-item/hooks.ts +++ b/web/src/components/message-item/hooks.ts @@ -3,6 +3,7 @@ import { useSetModalState } from '@/hooks/common-hooks'; import { IRemoveMessageById, useSpeechWithSse } from '@/hooks/logic-hooks'; import { IFeedbackRequestBody } from '@/interfaces/request/chat'; import { getMessagePureId } from '@/utils/chat'; +import { hexStringToUint8Array } from '@/utils/common-util'; import { SpeechPlayer } from 'openai-speech-stream-player'; import { useCallback, useEffect, useRef, useState } from 'react'; @@ -94,14 +95,14 @@ export const useSpeech = (content: string, audioBinary?: string) => { } }, [setIsPlaying, speech, isPlaying, pause]); - // useEffect(() => { - // if (audioBinary) { - // const units = hexStringToUint8Array(audioBinary); - // if (units) { - // player.current?.feed(units); - // } - // } - // }, [audioBinary]); + useEffect(() => { + if (audioBinary) { + const units = hexStringToUint8Array(audioBinary); + if (units) { + player.current?.feed(units); + } + } + }, [audioBinary]); useEffect(() => { initialize(); diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 8f8970e5..c7e90f20 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -362,9 +362,9 @@ The above is the content you need to summarize.`, The 'knowledge' is a very special variable which will be filled-in with the retrieved chunks. All the variables in 'System' should be curly bracketed.`, add: 'Add', - key: 'key', + key: 'Key', optional: 'Optional', - operation: 'operation', + operation: 'Operation', model: 'Model', modelTip: 'Large language chat model', modelMessage: 'Please select!', @@ -642,7 +642,7 @@ The above is the content you need to summarize.`, 'Loop is the upper limit of the number of loops of the current component, when the number of loops exceeds the value of loop, it means that the component can not complete the current task, please re-optimize agent', yes: 'Yes', no: 'No', - key: 'key', + key: 'Key', componentId: 'Component ID', add: 'Add', operation: 'operation', diff --git a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx index dddc81a3..fc0e3f1f 100644 --- a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx @@ -99,7 +99,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => { > */} - {/* { initialValue={false} > - */} + );