4.8.21 feature (#3742)
* model config * feat: normalization embedding * adapt unstrea reasoning response * remove select app * perf: dataset search code * fix: multiple audio video show * perf: query extension output * perf: link check * perf: faq doc * fix: ts * feat: support reasoning text output * feat: workflow support reasoning output
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import { useMarkdownWidth } from '../hooks';
|
||||
|
||||
const AudioBlock = ({ code: audioUrl }: { code: string }) => {
|
||||
const { width, Ref } = useMarkdownWidth();
|
||||
const audioRef = useRef<HTMLAudioElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(audioUrl?.trim(), {
|
||||
@@ -13,8 +14,7 @@ const AudioBlock = ({ code: audioUrl }: { code: string }) => {
|
||||
.then((response) => response.blob())
|
||||
.then((blob) => {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const audio = document.getElementById('player');
|
||||
audio?.setAttribute('src', url);
|
||||
audioRef?.current?.setAttribute('src', url);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
@@ -22,8 +22,8 @@ const AudioBlock = ({ code: audioUrl }: { code: string }) => {
|
||||
}, [audioUrl]);
|
||||
|
||||
return (
|
||||
<Box w={width} ref={Ref}>
|
||||
<audio id="player" controls style={{ width: '100%' }} />
|
||||
<Box w={width} ref={Ref} my={4}>
|
||||
<audio ref={audioRef} controls style={{ width: '100%' }} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import { useMarkdownWidth } from '../hooks';
|
||||
|
||||
const VideoBlock = ({ code: videoUrl }: { code: string }) => {
|
||||
const { width, Ref } = useMarkdownWidth();
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(videoUrl?.trim(), {
|
||||
@@ -13,8 +14,7 @@ const VideoBlock = ({ code: videoUrl }: { code: string }) => {
|
||||
.then((response) => response.blob())
|
||||
.then((blob) => {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const video = document.getElementById('player');
|
||||
video?.setAttribute('src', url);
|
||||
videoRef?.current?.setAttribute('src', url);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
@@ -22,8 +22,8 @@ const VideoBlock = ({ code: videoUrl }: { code: string }) => {
|
||||
}, [videoUrl]);
|
||||
|
||||
return (
|
||||
<Box w={width} ref={Ref}>
|
||||
<video id="player" controls />
|
||||
<Box w={width} ref={Ref} my={4} borderRadius={'md'} overflow={'hidden'}>
|
||||
<video ref={videoRef} controls />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -58,10 +58,10 @@ const MarkdownRender = ({ source = '', showAnimation, isDisabled, forbidZhFormat
|
||||
// 保护 URL 格式:https://, http://, /api/xxx
|
||||
const urlPlaceholders: string[] = [];
|
||||
const textWithProtectedUrls = source.replace(
|
||||
/(https?:\/\/[^\s<]+[^<.,:;"')\]\s]|\/api\/[^\s]+)(?=\s|$)/g,
|
||||
/https?:\/\/(?:(?:[\w-]+\.)+[a-zA-Z]{2,6}|localhost)(?::\d{2,5})?(?:\/[\w\-./?%&=@]*)?/g,
|
||||
(match) => {
|
||||
urlPlaceholders.push(match);
|
||||
return `__URL_${urlPlaceholders.length - 1}__`;
|
||||
return `__URL_${urlPlaceholders.length - 1}__ `;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -73,14 +73,14 @@ const MarkdownRender = ({ source = '', showAnimation, isDisabled, forbidZhFormat
|
||||
)
|
||||
// 处理引用标记
|
||||
.replace(/\n*(\[QUOTE SIGN\]\(.*\))/g, '$1')
|
||||
// 处理 [quote:id] 格式引用,将 [quote:675934a198f46329dfc6d05a] 转换为 [675934a198f46329dfc6d05a]()
|
||||
// 处理 [quote:id] 格式引用,将 [quote:675934a198f46329dfc6d05a] 转换为 [675934a198f46329dfc6d05a](QUOTE)
|
||||
.replace(/\[quote:?\s*([a-f0-9]{24})\](?!\()/gi, '[$1](QUOTE)')
|
||||
.replace(/\[([a-f0-9]{24})\](?!\()/g, '[$1](QUOTE)');
|
||||
|
||||
// 还原 URL
|
||||
const finalText = textWithSpaces.replace(
|
||||
/__URL_(\d+)__/g,
|
||||
(_, index) => urlPlaceholders[parseInt(index)]
|
||||
(_, index) => `${urlPlaceholders[parseInt(index)]}`
|
||||
);
|
||||
|
||||
return finalText;
|
||||
|
||||
@@ -99,6 +99,7 @@ const SettingLLMModel = ({
|
||||
<AISettingModal
|
||||
onClose={onCloseAIChatSetting}
|
||||
onSuccess={(e) => {
|
||||
console.log(e);
|
||||
onChange(e);
|
||||
onCloseAIChatSetting();
|
||||
}}
|
||||
|
||||
@@ -46,10 +46,11 @@ const TTSSelect = ({
|
||||
</HStack>
|
||||
),
|
||||
value: model.model,
|
||||
children: model.voices.map((voice) => ({
|
||||
label: voice.label,
|
||||
value: voice.value
|
||||
}))
|
||||
children:
|
||||
model.voices?.map((voice) => ({
|
||||
label: voice.label,
|
||||
value: voice.value
|
||||
})) || []
|
||||
};
|
||||
})
|
||||
],
|
||||
|
||||
@@ -226,7 +226,7 @@ const ChatBox = ({
|
||||
status,
|
||||
moduleName: name
|
||||
};
|
||||
} else if (event === SseResponseEventEnum.answer && reasoningText) {
|
||||
} else if (reasoningText) {
|
||||
if (lastValue.type === ChatItemValueTypeEnum.reasoning && lastValue.reasoning) {
|
||||
lastValue.reasoning.content += reasoningText;
|
||||
return {
|
||||
|
||||
@@ -194,6 +194,7 @@ export const WholeResponseContent = ({
|
||||
label={t('common:core.chat.response.module maxToken')}
|
||||
value={activeModule?.maxToken}
|
||||
/>
|
||||
<Row label={t('chat:reasoning_text')} value={activeModule?.reasoningText} />
|
||||
<Row
|
||||
label={t('common:core.chat.response.module historyPreview')}
|
||||
rawDom={
|
||||
@@ -238,6 +239,22 @@ export const WholeResponseContent = ({
|
||||
label={t('common:core.chat.response.search using reRank')}
|
||||
value={`${activeModule?.searchUsingReRank}`}
|
||||
/>
|
||||
{activeModule.queryExtensionResult && (
|
||||
<>
|
||||
<Row
|
||||
label={t('common:core.chat.response.Extension model')}
|
||||
value={activeModule.queryExtensionResult.model}
|
||||
/>
|
||||
<Row
|
||||
label={t('chat:query_extension_IO_tokens')}
|
||||
value={`${activeModule.queryExtensionResult.inputTokens}/${activeModule.queryExtensionResult.outputTokens}`}
|
||||
/>
|
||||
<Row
|
||||
label={t('common:support.wallet.usage.Extension result')}
|
||||
value={activeModule.queryExtensionResult.query}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<Row
|
||||
label={t('common:core.chat.response.Extension model')}
|
||||
value={activeModule?.extensionModel}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getCaptchaPic } from '@/web/support/user/api';
|
||||
import { Button, Input, Image, ModalBody, ModalFooter, Skeleton } from '@chakra-ui/react';
|
||||
import { Button, Input, ModalBody, ModalFooter, Skeleton } from '@chakra-ui/react';
|
||||
import MyImage from '@fastgpt/web/components/common/Image/MyImage';
|
||||
import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
@@ -16,7 +16,7 @@ const SendCodeAuthModal = ({
|
||||
onClose: () => void;
|
||||
|
||||
onSending: boolean;
|
||||
onSendCode: (params_0: { username: string; captcha: string }) => Promise<void>;
|
||||
onSendCode: (e: { username: string; captcha: string }) => Promise<void>;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -63,11 +63,16 @@ const SendCodeAuthModal = ({
|
||||
</Button>
|
||||
<Button
|
||||
isLoading={onSending}
|
||||
onClick={handleSubmit(({ code }) => {
|
||||
return onSendCode({ username, captcha: code }).then(() => {
|
||||
onClose();
|
||||
});
|
||||
})}
|
||||
onClick={handleSubmit(
|
||||
({ code }) => {
|
||||
return onSendCode({ username, captcha: code }).then(() => {
|
||||
onClose();
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
}
|
||||
)}
|
||||
>
|
||||
{t('common:common.Confirm')}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user