fix: đã sửa lỗi các tools của AI

This commit is contained in:
2026-07-22 09:27:12 +07:00
parent 022fbb3351
commit 4791bb22d9
4 changed files with 54 additions and 2 deletions
+27
View File
@@ -3056,6 +3056,9 @@ const App = () => {
isRunning: false
});
const [aiPrompt, setAiPrompt] = useState('');
const [promptHistory, setPromptHistory] = useState([]);
const [promptHistIdx, setPromptHistIdx] = useState(-1);
const promptHistRef = useRef([]);
const [aiProvider, setAiProvider] = useState('OpenAI');
const [aiModel, setAiModel] = useState('GPT-4o');
const [aiActionLog, setAiActionLog] = useState([]);
@@ -7057,6 +7060,11 @@ const App = () => {
time: Date.now()
}]);
}
if (prompt) {
promptHistRef.current = [...promptHistRef.current.slice(-49), prompt];
setPromptHistory(promptHistRef.current);
}
setPromptHistIdx(-1);
setAiActionLog(prev => [...prev, {
type: 'status',
text: ` Hoàn tất.`,
@@ -7485,6 +7493,9 @@ const App = () => {
}
}
detectedBPM = Math.round(Math.min(300, Math.max(30, detectedBPM)));
if (args.set_tempo !== false && detectedBPM > 0) {
setBpm(String(detectedBPM));
}
const bitDepth = 16;
const bitrate = Math.round(sr * channels * bitDepth / 1000);
return {
@@ -8451,6 +8462,22 @@ const App = () => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
handleAISend();
} else if (e.key === 'ArrowUp' && promptHistRef.current.length > 0) {
e.preventDefault();
const idx = promptHistIdx === -1 ? promptHistRef.current.length - 1 : Math.max(0, promptHistIdx - 1);
setPromptHistIdx(idx);
setAiPrompt(promptHistRef.current[idx]);
} else if (e.key === 'ArrowDown') {
e.preventDefault();
if (promptHistIdx === -1) return;
const idx = promptHistIdx + 1;
if (idx >= promptHistRef.current.length) {
setPromptHistIdx(-1);
setAiPrompt('');
} else {
setPromptHistIdx(idx);
setAiPrompt(promptHistRef.current[idx]);
}
}
}
}), /*#__PURE__*/React.createElement("div", {