2025-02-25 11:32:01 +08:00
|
|
|
import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
2025-06-17 11:57:07 +08:00
|
|
|
import { HandleType, Position } from '@xyflow/react';
|
2025-02-25 11:32:01 +08:00
|
|
|
import { createContext } from 'react';
|
2025-06-09 19:19:48 +08:00
|
|
|
import { useAddNode } from './hooks/use-add-node';
|
2025-06-11 09:22:07 +08:00
|
|
|
import { useCacheChatLog } from './hooks/use-cache-chat-log';
|
2025-07-28 16:48:59 +08:00
|
|
|
import { useShowFormDrawer, useShowLogSheet } from './hooks/use-show-drawer';
|
2025-02-25 11:32:01 +08:00
|
|
|
|
2025-06-06 17:54:59 +08:00
|
|
|
export const AgentFormContext = createContext<RAGFlowNodeType | undefined>(
|
2025-02-25 11:32:01 +08:00
|
|
|
undefined,
|
|
|
|
|
);
|
2025-06-09 19:19:48 +08:00
|
|
|
|
|
|
|
|
type AgentInstanceContextType = Pick<
|
|
|
|
|
ReturnType<typeof useAddNode>,
|
|
|
|
|
'addCanvasNode'
|
2025-07-28 16:48:59 +08:00
|
|
|
> &
|
|
|
|
|
Pick<ReturnType<typeof useShowFormDrawer>, 'showFormDrawer'>;
|
2025-06-09 19:19:48 +08:00
|
|
|
|
|
|
|
|
export const AgentInstanceContext = createContext<AgentInstanceContextType>(
|
|
|
|
|
{} as AgentInstanceContextType,
|
|
|
|
|
);
|
2025-06-11 09:22:07 +08:00
|
|
|
|
|
|
|
|
type AgentChatContextType = Pick<
|
|
|
|
|
ReturnType<typeof useShowLogSheet>,
|
|
|
|
|
'showLogSheet'
|
2025-07-31 16:09:45 +08:00
|
|
|
> & { setLastSendLoadingFunc: (loading: boolean, messageId: string) => void };
|
2025-06-11 09:22:07 +08:00
|
|
|
|
|
|
|
|
export const AgentChatContext = createContext<AgentChatContextType>(
|
|
|
|
|
{} as AgentChatContextType,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
type AgentChatLogContextType = Pick<
|
|
|
|
|
ReturnType<typeof useCacheChatLog>,
|
|
|
|
|
'addEventList' | 'setCurrentMessageId'
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
export const AgentChatLogContext = createContext<AgentChatLogContextType>(
|
|
|
|
|
{} as AgentChatLogContextType,
|
|
|
|
|
);
|
2025-06-17 11:57:07 +08:00
|
|
|
|
|
|
|
|
export type HandleContextType = {
|
|
|
|
|
nodeId?: string;
|
|
|
|
|
id?: string;
|
|
|
|
|
type: HandleType;
|
|
|
|
|
position: Position;
|
2025-08-14 17:48:02 +08:00
|
|
|
isFromConnectionDrag: boolean;
|
2025-06-17 11:57:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const HandleContext = createContext<HandleContextType>(
|
|
|
|
|
{} as HandleContextType,
|
|
|
|
|
);
|