mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-21 23:46:50 +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:
@@ -55,10 +55,6 @@ export default function ChatPage() {
|
|||||||
threadId: isNewThread ? undefined : threadId,
|
threadId: isNewThread ? undefined : threadId,
|
||||||
context: settings.context,
|
context: settings.context,
|
||||||
isMock,
|
isMock,
|
||||||
onSend: (_threadId) => {
|
|
||||||
setThreadId(_threadId);
|
|
||||||
setIsNewThread(false);
|
|
||||||
},
|
|
||||||
onStart: (createdThreadId) => {
|
onStart: (createdThreadId) => {
|
||||||
setThreadId(createdThreadId);
|
setThreadId(createdThreadId);
|
||||||
setIsNewThread(false);
|
setIsNewThread(false);
|
||||||
|
|||||||
@@ -364,6 +364,27 @@ export function useThreadStream({
|
|||||||
let uploadedFileInfo: UploadedFileInfo[] = [];
|
let uploadedFileInfo: UploadedFileInfo[] = [];
|
||||||
|
|
||||||
try {
|
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
|
// Upload files first if any
|
||||||
if (message.files && message.files.length > 0) {
|
if (message.files && message.files.length > 0) {
|
||||||
setIsUploading(true);
|
setIsUploading(true);
|
||||||
@@ -493,7 +514,7 @@ export function useThreadStream({
|
|||||||
sendInFlightRef.current = false;
|
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,
|
// Cache the latest thread messages in a ref to compare against incoming history messages for deduplication,
|
||||||
|
|||||||
Reference in New Issue
Block a user