Feat: Make the agent dialog window exposed to the outside world fill in the begin form #3221 (#9124)

### What problem does this PR solve?
Feat: Make the agent dialog window exposed to the outside world fill in
the begin form #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-07-31 09:34:45 +08:00
committed by GitHub
parent d9fe279dde
commit 6a170b2f6e
12 changed files with 141 additions and 32 deletions

View File

@ -176,6 +176,7 @@ export function useSetUploadResponseData() {
export const useSendAgentMessage = (
url?: string,
addEventList?: (data: IEventList, messageId: string) => void,
beginParams?: any[],
) => {
const { id: agentId } = useParams();
const { handleInputChange, value, setValue } = useHandleMessageInputChange();
@ -226,7 +227,9 @@ export const useSendAgentMessage = (
params.query = message.content;
// params.message_id = message.id;
params.inputs = transferInputsArrayToObject(query); // begin operator inputs
params.inputs = transferInputsArrayToObject(
beginParams ? beginParams : query,
); // begin operator inputs
params.files = uploadResponseList;
@ -248,13 +251,14 @@ export const useSendAgentMessage = (
},
[
agentId,
sessionId,
send,
clearUploadResponseList,
inputs,
beginParams,
uploadResponseList,
sessionId,
setValue,
removeLatestMessage,
clearUploadResponseList,
],
);

View File

@ -487,6 +487,16 @@ export const initialExeSqlValues = {
port: 3306,
password: '',
max_records: 1024,
outputs: {
formalized_content: {
value: '',
type: 'string',
},
json: {
value: [],
type: 'Array<Object>',
},
},
};
export const initialSwitchValues = {

View File

@ -20,10 +20,14 @@ import { useFormValues } from '../../hooks/use-form-values';
import { useWatchFormChange } from '../../hooks/use-watch-form-change';
import { INextOperatorForm } from '../../interface';
import { ExeSQLOptions } from '../../options';
import { buildOutputList } from '../../utils/build-output-list';
import { FormWrapper } from '../components/form-wrapper';
import { Output } from '../components/output';
import { QueryVariable } from '../components/query-variable';
import { FormSchema, useSubmitForm } from './use-submit-form';
const outputList = buildOutputList(initialExeSqlValues.outputs);
export function ExeSQLFormWidgets({ loading }: { loading: boolean }) {
const form = useFormContext();
const { t } = useTranslate('flow');
@ -153,6 +157,9 @@ function ExeSQLForm({ node }: INextOperatorForm) {
<QueryVariable name="sql"></QueryVariable>
<ExeSQLFormWidgets loading={loading}></ExeSQLFormWidgets>
</FormWrapper>
<div className="p-5">
<Output list={outputList}></Output>
</div>
</Form>
);
}

View File

@ -18,7 +18,6 @@ import {
import { SharedFrom } from '@/constants/chat';
import { useSetModalState } from '@/hooks/common-hooks';
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
import { ReactFlowProvider } from '@xyflow/react';
import {
ChevronDown,
@ -37,10 +36,7 @@ import AgentCanvas from './canvas';
import EmbedDialog from './embed-dialog';
import { useHandleExportOrImportJsonFile } from './hooks/use-export-json';
import { useFetchDataOnMount } from './hooks/use-fetch-data';
import {
useGetBeginNodeDataInputs,
useGetBeginNodeDataQueryIsSafe,
} from './hooks/use-get-begin-query';
import { useGetBeginNodeDataInputs } from './hooks/use-get-begin-query';
import {
useSaveGraph,
useSaveGraphBeforeOpeningDebugDrawer,
@ -69,7 +65,6 @@ export default function Agent() {
showModal: showChatDrawer,
} = useSetModalState();
const { t } = useTranslation();
const { data: userInfo } = useFetchUserInfo();
// const openDocument = useOpenDocument();
const {
@ -99,7 +94,6 @@ export default function Agent() {
const { showEmbedModal, hideEmbedModal, embedVisible, beta } =
useShowEmbedModal();
const { navigateToAgentLogs } = useNavigatePage();
const isBeginNodeDataQuerySafe = useGetBeginNodeDataQueryIsSafe();
return (
<section className="h-full">
@ -165,13 +159,7 @@ export default function Agent() {
{location.hostname !== 'demo.ragflow.io' && (
<>
<DropdownMenuSeparator />
<AgentDropdownMenuItem
onClick={showEmbedModal}
disabled={
!isBeginNodeDataQuerySafe ||
userInfo.nickname !== agentDetail.nickname
}
>
<AgentDropdownMenuItem onClick={showEmbedModal}>
<ScreenShare />
{t('common.embedIntoSite')}
</AgentDropdownMenuItem>