mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 11:18:22 +00:00
refactor(frontend): update thread hooks for new API structure
- page.tsx - simplify thread page component - hooks.ts - enhance thread hooks with new run APIs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4fa2c15613
commit
a0ab3a3dd4
@ -55,10 +55,6 @@ export default function ChatPage() {
|
||||
threadId: isNewThread ? undefined : threadId,
|
||||
context: settings.context,
|
||||
isMock,
|
||||
onSend: (_threadId) => {
|
||||
setThreadId(_threadId);
|
||||
setIsNewThread(false);
|
||||
},
|
||||
onStart: (createdThreadId) => {
|
||||
setThreadId(createdThreadId);
|
||||
setIsNewThread(false);
|
||||
|
||||
@ -364,6 +364,27 @@ export function useThreadStream({
|
||||
let uploadedFileInfo: UploadedFileInfo[] = [];
|
||||
|
||||
try {
|
||||
if (!isMock && threadId) {
|
||||
await fetch(`${getBackendBaseURL()}/api/threads`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
body: JSON.stringify({
|
||||
thread_id: threadId,
|
||||
assistant_id:
|
||||
typeof extraContext?.agent_name === "string"
|
||||
? extraContext.agent_name
|
||||
: undefined,
|
||||
metadata:
|
||||
typeof extraContext?.agent_name === "string"
|
||||
? { agent_name: extraContext.agent_name }
|
||||
: {},
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
// Upload files first if any
|
||||
if (message.files && message.files.length > 0) {
|
||||
setIsUploading(true);
|
||||
@ -493,7 +514,7 @@ export function useThreadStream({
|
||||
sendInFlightRef.current = false;
|
||||
}
|
||||
},
|
||||
[thread, t.uploads.uploadingFiles, context, queryClient],
|
||||
[thread, t.uploads.uploadingFiles, context, queryClient, isMock],
|
||||
);
|
||||
|
||||
// Cache the latest thread messages in a ref to compare against incoming history messages for deduplication,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user