bug修改
This commit is contained in:
1 parent
f4769c4046
commit
139dfb76e4
4 files changed
+29
-3
No files matched your search
@@ -5,6 +5,8 @@ import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|||||||
import { QueryClientProvider } from "@/components/query-client-provider";
|
import { QueryClientProvider } from "@/components/query-client-provider";
|
||||||
import { I18nProvider } from "@/core/i18n/context";
|
import { I18nProvider } from "@/core/i18n/context";
|
||||||
import { detectLocale } from "@/core/i18n/locale";
|
import { detectLocale } from "@/core/i18n/locale";
|
||||||
|
import { ChatProvider } from "@/contexts/ChatContext";
|
||||||
|
import { ThemeProvider } from "@/contexts/ThemeContext";
|
||||||
|
|
||||||
import { HashRouter, useLocation } from "react-router-dom";
|
import { HashRouter, useLocation } from "react-router-dom";
|
||||||
|
|
||||||
@@ -26,7 +28,11 @@ function AppProviders({ children }: { children: React.ReactNode }) {
|
|||||||
forcedTheme={forcedTheme}
|
forcedTheme={forcedTheme}
|
||||||
>
|
>
|
||||||
<I18nProvider initialLocale={locale}>
|
<I18nProvider initialLocale={locale}>
|
||||||
<QueryClientProvider>{children}</QueryClientProvider>
|
<ThemeProvider>
|
||||||
|
<ChatProvider>
|
||||||
|
<QueryClientProvider>{children}</QueryClientProvider>
|
||||||
|
</ChatProvider>
|
||||||
|
</ThemeProvider>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
</NextThemesProvider>
|
</NextThemesProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ function ClarificationCard({
|
|||||||
const payload = getClarificationPayload(message);
|
const payload = getClarificationPayload(message);
|
||||||
const [customAnswer, setCustomAnswer] = useState("");
|
const [customAnswer, setCustomAnswer] = useState("");
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [submitted, setSubmitted] = useState(false);
|
||||||
|
|
||||||
const options = useMemo(
|
const options = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -473,16 +474,17 @@ function ClarificationCard({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const disabled = isLoading || submitting || !onSubmit;
|
const disabled = false;
|
||||||
|
|
||||||
async function submitAnswer(answer: string) {
|
async function submitAnswer(answer: string) {
|
||||||
const trimmed = answer.trim();
|
const trimmed = answer.trim();
|
||||||
if (!trimmed || disabled) {
|
if (!trimmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
try {
|
try {
|
||||||
await onSubmit?.(trimmed);
|
await onSubmit?.(trimmed);
|
||||||
|
setSubmitted(true);
|
||||||
} finally {
|
} finally {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,14 @@ export default function AgentChatPage() {
|
|||||||
[sendMessage, threadId, agent_id],
|
[sendMessage, threadId, agent_id],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleClarificationSubmit = useCallback(
|
||||||
|
(answer: string) => {
|
||||||
|
setHasStartedConversation(true);
|
||||||
|
void sendMessage(threadId, { text: answer, files: [] }, { agent_id });
|
||||||
|
},
|
||||||
|
[sendMessage, threadId, agent_id],
|
||||||
|
);
|
||||||
|
|
||||||
const handleStop = useCallback(async () => {
|
const handleStop = useCallback(async () => {
|
||||||
await thread.stop();
|
await thread.stop();
|
||||||
}, [thread]);
|
}, [thread]);
|
||||||
@@ -160,6 +168,7 @@ export default function AgentChatPage() {
|
|||||||
thread={thread}
|
thread={thread}
|
||||||
paddingBottom={messageListPaddingBottom}
|
paddingBottom={messageListPaddingBottom}
|
||||||
tokenUsageEnabled={tokenUsageEnabled}
|
tokenUsageEnabled={tokenUsageEnabled}
|
||||||
|
onClarificationSubmit={handleClarificationSubmit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,14 @@ export default function ChatPage() {
|
|||||||
},
|
},
|
||||||
[sendMessage, threadId],
|
[sendMessage, threadId],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleClarificationSubmit = useCallback(
|
||||||
|
(answer: string) => {
|
||||||
|
setHasStartedConversation(true);
|
||||||
|
void sendMessage(threadId, { text: answer, files: [] });
|
||||||
|
},
|
||||||
|
[sendMessage, threadId],
|
||||||
|
);
|
||||||
const handleStop = useCallback(async () => {
|
const handleStop = useCallback(async () => {
|
||||||
await thread.stop();
|
await thread.stop();
|
||||||
}, [thread]);
|
}, [thread]);
|
||||||
@@ -137,6 +145,7 @@ export default function ChatPage() {
|
|||||||
thread={thread}
|
thread={thread}
|
||||||
paddingBottom={messageListPaddingBottom}
|
paddingBottom={messageListPaddingBottom}
|
||||||
tokenUsageEnabled={tokenUsageEnabled}
|
tokenUsageEnabled={tokenUsageEnabled}
|
||||||
|
onClarificationSubmit={handleClarificationSubmit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute right-0 bottom-0 left-0 z-30 flex justify-center px-4">
|
<div className="absolute right-0 bottom-0 left-0 z-30 flex justify-center px-4">
|
||||||
|
|||||||
Reference in new issue
Block a user