mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Upload files on the data flow page #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
34
web/src/pages/data-flow/hooks/use-run-dataflow.ts
Normal file
34
web/src/pages/data-flow/hooks/use-run-dataflow.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { useSendMessageBySSE } from '@/hooks/use-send-message';
|
||||
import api from '@/utils/api';
|
||||
import { useCallback } from 'react';
|
||||
import { useParams } from 'umi';
|
||||
import { useSaveGraphBeforeOpeningDebugDrawer } from './use-save-graph';
|
||||
|
||||
export function useRunDataflow(showLogSheet: () => void) {
|
||||
const { send } = useSendMessageBySSE(api.runCanvas);
|
||||
const { id } = useParams();
|
||||
|
||||
const { handleRun: saveGraph, loading } =
|
||||
useSaveGraphBeforeOpeningDebugDrawer(showLogSheet!);
|
||||
|
||||
const run = useCallback(
|
||||
async (fileResponseData: Record<string, any>) => {
|
||||
const success = await saveGraph();
|
||||
if (!success) return;
|
||||
const res = await send({
|
||||
id,
|
||||
query: '',
|
||||
session_id: null,
|
||||
inputs: fileResponseData,
|
||||
});
|
||||
console.log('🚀 ~ useRunDataflow ~ res:', res);
|
||||
|
||||
if (res && res?.response.status === 200 && res?.data?.code === 0) {
|
||||
// fetch canvas
|
||||
}
|
||||
},
|
||||
[id, saveGraph, send],
|
||||
);
|
||||
|
||||
return { run, loading: loading };
|
||||
}
|
||||
Reference in New Issue
Block a user