Feat: Fixed the issue where the begin operator parameters could not be submitted during debugging #3221 (#8539)

### What problem does this PR solve?

Feat: Fixed the issue where the begin operator parameters could not be
submitted during debugging #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-06-27 18:53:13 +08:00
committed by GitHub
parent 0f7c955634
commit 8e1f8a0c48
6 changed files with 44 additions and 25 deletions

View File

@ -11,6 +11,7 @@ export enum MessageEventType {
Message = 'message', Message = 'message',
MessageEnd = 'message_end', MessageEnd = 'message_end',
WorkflowFinished = 'workflow_finished', WorkflowFinished = 'workflow_finished',
UserInputs = 'user_inputs',
} }
export interface IAnswerEvent<T> { export interface IAnswerEvent<T> {

View File

@ -83,8 +83,6 @@ export const useSendNextMessage = () => {
loading, loading,
derivedMessages, derivedMessages,
ref, ref,
addNewestQuestion,
addNewestAnswer,
removeLatestMessage, removeLatestMessage,
removeMessageById, removeMessageById,
addNewestOneQuestion, addNewestOneQuestion,

View File

@ -852,6 +852,7 @@ export const RestrictedUpstreamMap = {
[Operator.Agent]: [Operator.Begin], [Operator.Agent]: [Operator.Begin],
[Operator.TavilySearch]: [Operator.Begin], [Operator.TavilySearch]: [Operator.Begin],
[Operator.StringTransform]: [Operator.Begin], [Operator.StringTransform]: [Operator.Begin],
[Operator.UserFillUp]: [Operator.Begin],
}; };
export const NodeMap = { export const NodeMap = {

View File

@ -263,7 +263,6 @@ const DebugContent = ({
const onSubmit = useCallback( const onSubmit = useCallback(
(values: z.infer<typeof FormSchema>) => { (values: z.infer<typeof FormSchema>) => {
console.log('🚀 ~ values:', values); console.log('🚀 ~ values:', values);
return values;
const nextValues = Object.entries(values).map(([key, value]) => { const nextValues = Object.entries(values).map(([key, value]) => {
const item = parameters[Number(key)]; const item = parameters[Number(key)];
let nextValue = value; let nextValue = value;

View File

@ -6,6 +6,7 @@ import {
FormLabel, FormLabel,
FormMessage, FormMessage,
} from '@/components/ui/form'; } from '@/components/ui/form';
import { toLower } from 'lodash';
import { ReactNode, useMemo } from 'react'; import { ReactNode, useMemo } from 'react';
import { useFormContext } from 'react-hook-form'; import { useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -31,7 +32,10 @@ export function QueryVariable({
const finalOptions = useMemo(() => { const finalOptions = useMemo(() => {
return type return type
? nextOptions.map((x) => { ? nextOptions.map((x) => {
return { ...x, options: x.options.filter((y) => y.type === type) }; return {
...x,
options: x.options.filter((y) => toLower(y.type).startsWith(type)),
};
}) })
: nextOptions; : nextOptions;
}, [nextOptions, type]); }, [nextOptions, type]);

View File

@ -1,5 +1,11 @@
import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
} from '@/components/ui/sheet';
import { IModalProps } from '@/interfaces/common'; import { IModalProps } from '@/interfaces/common';
import { Drawer } from 'antd'; import { cn } from '@/lib/utils';
import { useCallback } from 'react'; import { useCallback } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { BeginId } from '../constant'; import { BeginId } from '../constant';
@ -8,14 +14,13 @@ import { useGetBeginNodeDataQuery } from '../hooks/use-get-begin-query';
import { useSaveGraphBeforeOpeningDebugDrawer } from '../hooks/use-save-graph'; import { useSaveGraphBeforeOpeningDebugDrawer } from '../hooks/use-save-graph';
import { BeginQuery } from '../interface'; import { BeginQuery } from '../interface';
import useGraphStore from '../store'; import useGraphStore from '../store';
import { getDrawerWidth } from '../utils';
const RunSheet = ({ const RunSheet = ({
hideModal, hideModal,
showModal: showChatModal, showModal: showChatModal,
}: IModalProps<any>) => { }: IModalProps<any>) => {
const { t } = useTranslation(); const { t } = useTranslation();
const updateNodeForm = useGraphStore((state) => state.updateNodeForm); const { updateNodeForm, getNode } = useGraphStore((state) => state);
const getBeginNodeDataQuery = useGetBeginNodeDataQuery(); const getBeginNodeDataQuery = useGetBeginNodeDataQuery();
const query: BeginQuery[] = getBeginNodeDataQuery(); const query: BeginQuery[] = getBeginNodeDataQuery();
@ -25,12 +30,26 @@ const RunSheet = ({
); );
const handleRunAgent = useCallback( const handleRunAgent = useCallback(
(nextValues: Record<string, any>) => { (nextValues: BeginQuery[]) => {
const currentNodes = updateNodeForm(BeginId, nextValues, ['query']); const beginNode = getNode(BeginId);
const inputs: Record<string, BeginQuery> = beginNode?.data.form.inputs;
const nextInputs = Object.keys(inputs).reduce<Record<string, BeginQuery>>(
(pre, key) => {
const item = nextValues.find((x) => x.key === key);
if (item) {
pre[key] = { ...item };
}
return pre;
},
{},
);
const currentNodes = updateNodeForm(BeginId, nextInputs, ['inputs']);
handleRun(currentNodes); handleRun(currentNodes);
hideModal?.(); hideModal?.();
}, },
[handleRun, hideModal, updateNodeForm], [getNode, handleRun, hideModal, updateNodeForm],
); );
const onOk = useCallback( const onOk = useCallback(
@ -41,21 +60,18 @@ const RunSheet = ({
); );
return ( return (
<Drawer <Sheet onOpenChange={hideModal} open>
title={t('flow.testRun')} <SheetContent className={cn('top-20 p-2')}>
placement="right" <SheetHeader>
onClose={hideModal} <SheetTitle>{t('flow.testRun')}</SheetTitle>
open <DebugContent
getContainer={false} ok={onOk}
width={getDrawerWidth()} parameters={query}
mask={false} loading={loading}
> ></DebugContent>
<DebugContent </SheetHeader>
ok={onOk} </SheetContent>
parameters={query} </Sheet>
loading={loading}
></DebugContent>
</Drawer>
); );
}; };