mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 00:46:52 +08:00
Feat: The agent's external page should be able to fill in the begin parameter after being reset in task mode #9745 (#9982)
### What problem does this PR solve? Feat: The agent's external page should be able to fill in the begin parameter after being reset in task mode #9745 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
import { SharedFrom } from '@/constants/chat';
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { useFetchExternalAgentInputs } from '@/hooks/use-agent-request';
|
||||
import { IEventList } from '@/hooks/use-send-message';
|
||||
import {
|
||||
buildRequestBody,
|
||||
useSendAgentMessage,
|
||||
} from '@/pages/agent/chat/use-send-agent-message';
|
||||
import { isEmpty } from 'lodash';
|
||||
import trim from 'lodash/trim';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useSearchParams } from 'umi';
|
||||
import { AgentDialogueMode } from '../constant';
|
||||
|
||||
export const useSendButtonDisabled = (value: string) => {
|
||||
return trim(value) === '';
|
||||
@ -35,12 +38,15 @@ export const useGetSharedChatSearchParams = () => {
|
||||
|
||||
export const useSendNextSharedMessage = (
|
||||
addEventList: (data: IEventList, messageId: string) => void,
|
||||
isTaskMode: boolean,
|
||||
) => {
|
||||
const { from, sharedId: conversationId } = useGetSharedChatSearchParams();
|
||||
const url = `/api/v1/${from === SharedFrom.Agent ? 'agentbots' : 'chatbots'}/${conversationId}/completions`;
|
||||
const { data: inputsData } = useFetchExternalAgentInputs();
|
||||
|
||||
const [params, setParams] = useState<any[]>([]);
|
||||
const sendedTaskMessage = useRef<boolean>(false);
|
||||
|
||||
const isTaskMode = inputsData.mode === AgentDialogueMode.Task;
|
||||
|
||||
const {
|
||||
visible: parameterDialogVisible,
|
||||
@ -73,10 +79,27 @@ export const useSendNextSharedMessage = (
|
||||
[hideParameterDialog, isTaskMode, ret],
|
||||
);
|
||||
|
||||
const runTask = useCallback(() => {
|
||||
if (
|
||||
isTaskMode &&
|
||||
isEmpty(inputsData?.inputs) &&
|
||||
!sendedTaskMessage.current
|
||||
) {
|
||||
ok([]);
|
||||
sendedTaskMessage.current = true;
|
||||
}
|
||||
}, [inputsData?.inputs, isTaskMode, ok]);
|
||||
|
||||
useEffect(() => {
|
||||
runTask();
|
||||
}, [runTask]);
|
||||
|
||||
return {
|
||||
...ret,
|
||||
hasError: false,
|
||||
parameterDialogVisible,
|
||||
inputsData,
|
||||
isTaskMode,
|
||||
hideParameterDialog,
|
||||
showParameterDialog,
|
||||
ok,
|
||||
|
||||
Reference in New Issue
Block a user