mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-07-16 17:15:22 +00:00
fix(chat): avoid handleChat temporal dead zone (#3132)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -127,17 +127,6 @@ const Chat: React.FC = () => {
|
||||
const [knowledgeValue, setKnowledgeValue] = useState<string | null>(null);
|
||||
const [modelValue, setModelValue] = useState<string>('');
|
||||
|
||||
// Auto-send init message if present
|
||||
useEffect(() => {
|
||||
if (initMsg && chatId && !history.length && !replyLoading) {
|
||||
// Small delay to ensure everything is loaded
|
||||
const timer = setTimeout(() => {
|
||||
handleChat(initMsg);
|
||||
}, 500);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [chatId, handleChat, history.length, initMsg, replyLoading]);
|
||||
|
||||
useEffect(() => {
|
||||
setTemperatureValue(appInfo?.param_need?.filter(item => item.type === 'temperature')[0]?.value || 0.6);
|
||||
setMaxNewTokensValue(appInfo?.param_need?.filter(item => item.type === 'max_new_tokens')[0]?.value || 4000);
|
||||
@@ -343,6 +332,17 @@ const Chat: React.FC = () => {
|
||||
[chat, chatId, history, modelValue, scene],
|
||||
);
|
||||
|
||||
// Auto-send init message if present
|
||||
useEffect(() => {
|
||||
if (initMsg && chatId && !history.length && !replyLoading) {
|
||||
// Small delay to ensure everything is loaded
|
||||
const timer = setTimeout(() => {
|
||||
handleChat(initMsg);
|
||||
}, 500);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [chatId, handleChat, history.length, initMsg, replyLoading]);
|
||||
|
||||
useAsyncEffect(async () => {
|
||||
// 如果是默认小助手,不获取历史记录
|
||||
if (isChatDefault) {
|
||||
|
||||
Reference in New Issue
Block a user