mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 02:58:59 +08:00
### What problem does this PR solve? Feat: Add the WaitingDialogue operator. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
add4b13856
commit
48294e624c
@ -21,6 +21,7 @@ import {
|
|||||||
componentMenuList,
|
componentMenuList,
|
||||||
operatorMap,
|
operatorMap,
|
||||||
} from './constant';
|
} from './constant';
|
||||||
|
import { useHandleDrag } from './hooks';
|
||||||
import OperatorIcon from './operator-icon';
|
import OperatorIcon from './operator-icon';
|
||||||
|
|
||||||
type OperatorItem = {
|
type OperatorItem = {
|
||||||
@ -28,8 +29,14 @@ type OperatorItem = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function OperatorCard({ name }: OperatorItem) {
|
function OperatorCard({ name }: OperatorItem) {
|
||||||
|
const { handleDragStart } = useHandleDrag();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="bg-colors-background-inverse-weak border-colors-outline-neutral-standard">
|
<Card
|
||||||
|
draggable
|
||||||
|
onDragStart={handleDragStart(name)}
|
||||||
|
className="bg-colors-background-inverse-weak border-colors-outline-neutral-standard cursor-pointer"
|
||||||
|
>
|
||||||
<CardContent className="p-2 flex items-center gap-2">
|
<CardContent className="p-2 flex items-center gap-2">
|
||||||
<OperatorIcon
|
<OperatorIcon
|
||||||
name={name}
|
name={name}
|
||||||
|
@ -63,6 +63,7 @@ import {
|
|||||||
CodeXml,
|
CodeXml,
|
||||||
IterationCcw,
|
IterationCcw,
|
||||||
ListOrdered,
|
ListOrdered,
|
||||||
|
MessageSquareMore,
|
||||||
OptionIcon,
|
OptionIcon,
|
||||||
TextCursorInput,
|
TextCursorInput,
|
||||||
ToggleLeft,
|
ToggleLeft,
|
||||||
@ -109,6 +110,7 @@ export enum Operator {
|
|||||||
Iteration = 'Iteration',
|
Iteration = 'Iteration',
|
||||||
IterationStart = 'IterationItem',
|
IterationStart = 'IterationItem',
|
||||||
Code = 'Code',
|
Code = 'Code',
|
||||||
|
WaitingDialogue = 'WaitingDialogue',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CommonOperatorList = Object.values(Operator).filter(
|
export const CommonOperatorList = Object.values(Operator).filter(
|
||||||
@ -127,6 +129,7 @@ export const AgentOperatorList = [
|
|||||||
Operator.Concentrator,
|
Operator.Concentrator,
|
||||||
Operator.Template,
|
Operator.Template,
|
||||||
Operator.Iteration,
|
Operator.Iteration,
|
||||||
|
Operator.WaitingDialogue,
|
||||||
Operator.Note,
|
Operator.Note,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -168,6 +171,7 @@ export const operatorIconMap = {
|
|||||||
[Operator.Iteration]: IterationCcw,
|
[Operator.Iteration]: IterationCcw,
|
||||||
[Operator.IterationStart]: CirclePower,
|
[Operator.IterationStart]: CirclePower,
|
||||||
[Operator.Code]: CodeXml,
|
[Operator.Code]: CodeXml,
|
||||||
|
[Operator.WaitingDialogue]: MessageSquareMore,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const operatorMap: Record<
|
export const operatorMap: Record<
|
||||||
@ -307,6 +311,7 @@ export const operatorMap: Record<
|
|||||||
[Operator.Iteration]: { backgroundColor: '#e6f7ff' },
|
[Operator.Iteration]: { backgroundColor: '#e6f7ff' },
|
||||||
[Operator.IterationStart]: { backgroundColor: '#e6f7ff' },
|
[Operator.IterationStart]: { backgroundColor: '#e6f7ff' },
|
||||||
[Operator.Code]: { backgroundColor: '#4c5458' },
|
[Operator.Code]: { backgroundColor: '#4c5458' },
|
||||||
|
[Operator.WaitingDialogue]: { backgroundColor: '#a5d65c' },
|
||||||
};
|
};
|
||||||
|
|
||||||
export const componentMenuList = [
|
export const componentMenuList = [
|
||||||
@ -347,6 +352,9 @@ export const componentMenuList = [
|
|||||||
{
|
{
|
||||||
name: Operator.Code,
|
name: Operator.Code,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: Operator.WaitingDialogue,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: Operator.Note,
|
name: Operator.Note,
|
||||||
},
|
},
|
||||||
@ -670,6 +678,8 @@ export const initialCodeValues = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const initialWaitingDialogueValues = {};
|
||||||
|
|
||||||
export const CategorizeAnchorPointPositions = [
|
export const CategorizeAnchorPointPositions = [
|
||||||
{ top: 1, right: 34 },
|
{ top: 1, right: 34 },
|
||||||
{ top: 8, right: 18 },
|
{ top: 8, right: 18 },
|
||||||
@ -752,6 +762,7 @@ export const RestrictedUpstreamMap = {
|
|||||||
[Operator.Iteration]: [Operator.Begin],
|
[Operator.Iteration]: [Operator.Begin],
|
||||||
[Operator.IterationStart]: [Operator.Begin],
|
[Operator.IterationStart]: [Operator.Begin],
|
||||||
[Operator.Code]: [Operator.Begin],
|
[Operator.Code]: [Operator.Begin],
|
||||||
|
[Operator.WaitingDialogue]: [Operator.Begin],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NodeMap = {
|
export const NodeMap = {
|
||||||
@ -792,6 +803,7 @@ export const NodeMap = {
|
|||||||
[Operator.Iteration]: 'group',
|
[Operator.Iteration]: 'group',
|
||||||
[Operator.IterationStart]: 'iterationStartNode',
|
[Operator.IterationStart]: 'iterationStartNode',
|
||||||
[Operator.Code]: 'ragNode',
|
[Operator.Code]: 'ragNode',
|
||||||
|
[Operator.WaitingDialogue]: 'ragNode',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LanguageOptions = [
|
export const LanguageOptions = [
|
||||||
|
@ -170,6 +170,15 @@ export function useFormConfigMap() {
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
[Operator.WaitingDialogue]: {
|
||||||
|
component: CodeForm,
|
||||||
|
defaultValues: {},
|
||||||
|
schema: z.object({
|
||||||
|
arguments: z.array(
|
||||||
|
z.object({ name: z.string(), component_id: z.string() }),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
},
|
||||||
[Operator.Baidu]: {
|
[Operator.Baidu]: {
|
||||||
component: BaiduForm,
|
component: BaiduForm,
|
||||||
defaultValues: { top_n: 10 },
|
defaultValues: { top_n: 10 },
|
||||||
|
@ -40,7 +40,7 @@ interface IProps {
|
|||||||
showModal(index: number, record: BeginQuery): void;
|
showModal(index: number, record: BeginQuery): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function QueryTable({ data, deleteRecord, showModal }: IProps) {
|
export function QueryTable({ data = [], deleteRecord, showModal }: IProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [sorting, setSorting] = React.useState<SortingState>([]);
|
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||||
|
77
web/src/pages/agent/form/waiting-dialogue-form/index.tsx
Normal file
77
web/src/pages/agent/form/waiting-dialogue-form/index.tsx
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import Editor, { loader } from '@monaco-editor/react';
|
||||||
|
import { INextOperatorForm } from '../../interface';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from '@/components/ui/form';
|
||||||
|
import { RAGFlowSelect } from '@/components/ui/select';
|
||||||
|
import { ProgrammingLanguage } from '@/constants/agent';
|
||||||
|
import { ICodeForm } from '@/interfaces/database/flow';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
loader.config({ paths: { vs: '/vs' } });
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
ProgrammingLanguage.Python,
|
||||||
|
ProgrammingLanguage.Javascript,
|
||||||
|
].map((x) => ({ value: x, label: x }));
|
||||||
|
|
||||||
|
const CodeForm = ({ form, node }: INextOperatorForm) => {
|
||||||
|
const formData = node?.data.form as ICodeForm;
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form {...form}>
|
||||||
|
<form
|
||||||
|
className="p-5 space-y-5"
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="script"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel className="flex items-center justify-between">
|
||||||
|
Code
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="lang"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<RAGFlowSelect {...field} options={options} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Editor
|
||||||
|
height={300}
|
||||||
|
theme="vs-dark"
|
||||||
|
language={formData.lang}
|
||||||
|
options={{
|
||||||
|
minimap: { enabled: false },
|
||||||
|
automaticLayout: true,
|
||||||
|
}}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CodeForm;
|
@ -39,8 +39,6 @@ export const useHandleFormValuesChange = (
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const subscription = form?.watch((value, { name, type, values }) => {
|
const subscription = form?.watch((value, { name, type, values }) => {
|
||||||
console.log('🚀 ~ subscription ~ value:', value);
|
|
||||||
|
|
||||||
if (id && name) {
|
if (id && name) {
|
||||||
console.log(
|
console.log(
|
||||||
'🚀 ~ useEffect ~ value:',
|
'🚀 ~ useEffect ~ value:',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user