mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-22 22:26:43 +08:00
### What problem does this PR solve? Feat: Add suffix field to all operators #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -17,10 +17,16 @@ interface IProps {
|
|||||||
|
|
||||||
export const DelimiterInput = forwardRef<HTMLInputElement, InputProps & IProps>(
|
export const DelimiterInput = forwardRef<HTMLInputElement, InputProps & IProps>(
|
||||||
({ value, onChange, maxLength, defaultValue, ...props }, ref) => {
|
({ value, onChange, maxLength, defaultValue, ...props }, ref) => {
|
||||||
const nextValue = value?.replaceAll('\n', '\\n');
|
const nextValue = value
|
||||||
|
?.replaceAll('\n', '\\n')
|
||||||
|
.replaceAll('\t', '\\t')
|
||||||
|
.replaceAll('\r', '\\r');
|
||||||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const val = e.target.value;
|
const val = e.target.value;
|
||||||
const nextValue = val.replaceAll('\\n', '\n');
|
const nextValue = val
|
||||||
|
.replaceAll('\\n', '\n')
|
||||||
|
.replaceAll('\\t', '\t')
|
||||||
|
.replaceAll('\\r', '\r');
|
||||||
onChange?.(nextValue);
|
onChange?.(nextValue);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -381,7 +381,24 @@ export const initialSplitterValues = {
|
|||||||
delimiters: [{ value: '\n' }],
|
delimiters: [{ value: '\n' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initialHierarchicalMergerValues = { outputs: {} };
|
export enum Hierarchy {
|
||||||
|
H1 = '1',
|
||||||
|
H2 = '2',
|
||||||
|
H3 = '3',
|
||||||
|
H4 = '4',
|
||||||
|
H5 = '5',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initialHierarchicalMergerValues = {
|
||||||
|
outputs: {},
|
||||||
|
hierarchy: Hierarchy.H3,
|
||||||
|
levels: [
|
||||||
|
{ expressions: [{ expression: '^#[^#]' }] },
|
||||||
|
{ expressions: [{ expression: '^##[^#]' }] },
|
||||||
|
{ expressions: [{ expression: '^###[^#]' }] },
|
||||||
|
{ expressions: [{ expression: '^####[^#]' }] },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
export const CategorizeAnchorPointPositions = [
|
export const CategorizeAnchorPointPositions = [
|
||||||
{ top: 1, right: 34 },
|
{ top: 1, right: 34 },
|
||||||
@ -463,8 +480,36 @@ export enum FileType {
|
|||||||
Image = 'image',
|
Image = 'image',
|
||||||
Email = 'email',
|
Email = 'email',
|
||||||
TextMarkdown = 'text&markdown',
|
TextMarkdown = 'text&markdown',
|
||||||
Docx = 'docx',
|
Docx = 'word',
|
||||||
PowerPoint = 'ppt',
|
PowerPoint = 'ppt',
|
||||||
Video = 'video',
|
Video = 'video',
|
||||||
Audio = 'audio',
|
Audio = 'audio',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const FileTypeSuffixMap = {
|
||||||
|
[FileType.PDF]: ['pdf'],
|
||||||
|
[FileType.Spreadsheet]: ['xls', 'xlsx', 'csv'],
|
||||||
|
[FileType.Image]: ['jpg', 'jpeg', 'png', 'gif'],
|
||||||
|
[FileType.Email]: ['eml', 'msg'],
|
||||||
|
[FileType.TextMarkdown]: ['md', 'markdown', 'mdx', 'txt'],
|
||||||
|
[FileType.Docx]: ['doc', 'docx'],
|
||||||
|
[FileType.PowerPoint]: ['pptx'],
|
||||||
|
[FileType.Video]: [],
|
||||||
|
[FileType.Audio]: [
|
||||||
|
'da',
|
||||||
|
'wave',
|
||||||
|
'wav',
|
||||||
|
'mp3',
|
||||||
|
'aac',
|
||||||
|
'flac',
|
||||||
|
'ogg',
|
||||||
|
'aiff',
|
||||||
|
'au',
|
||||||
|
'midi',
|
||||||
|
'wma',
|
||||||
|
'realaudio',
|
||||||
|
'vqf',
|
||||||
|
'oggvorbis',
|
||||||
|
'ape',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { memo } from 'react';
|
|||||||
import { useFieldArray, useForm, useFormContext } from 'react-hook-form';
|
import { useFieldArray, useForm, useFormContext } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { initialHierarchicalMergerValues } from '../../constant';
|
import { Hierarchy, initialHierarchicalMergerValues } from '../../constant';
|
||||||
import { useFormValues } from '../../hooks/use-form-values';
|
import { useFormValues } from '../../hooks/use-form-values';
|
||||||
import { useWatchFormChange } from '../../hooks/use-watch-form-change';
|
import { useWatchFormChange } from '../../hooks/use-watch-form-change';
|
||||||
import { INextOperatorForm } from '../../interface';
|
import { INextOperatorForm } from '../../interface';
|
||||||
@ -20,14 +20,6 @@ import { Output } from '../components/output';
|
|||||||
|
|
||||||
const outputList = buildOutputList(initialHierarchicalMergerValues.outputs);
|
const outputList = buildOutputList(initialHierarchicalMergerValues.outputs);
|
||||||
|
|
||||||
enum Hierarchy {
|
|
||||||
H1 = '1',
|
|
||||||
H2 = '2',
|
|
||||||
H3 = '3',
|
|
||||||
H4 = '4',
|
|
||||||
H5 = '5',
|
|
||||||
}
|
|
||||||
|
|
||||||
const HierarchyOptions = [
|
const HierarchyOptions = [
|
||||||
{ label: 'H1', value: Hierarchy.H1 },
|
{ label: 'H1', value: Hierarchy.H1 },
|
||||||
{ label: 'H2', value: Hierarchy.H2 },
|
{ label: 'H2', value: Hierarchy.H2 },
|
||||||
@ -37,7 +29,7 @@ const HierarchyOptions = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const FormSchema = z.object({
|
export const FormSchema = z.object({
|
||||||
hierarchy: z.number(),
|
hierarchy: z.string(),
|
||||||
levels: z.array(
|
levels: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
expressions: z.array(
|
expressions: z.array(
|
||||||
|
|||||||
@ -1,3 +1,84 @@
|
|||||||
|
import {
|
||||||
|
Timeline,
|
||||||
|
TimelineContent,
|
||||||
|
TimelineDate,
|
||||||
|
TimelineHeader,
|
||||||
|
TimelineIndicator,
|
||||||
|
TimelineItem,
|
||||||
|
TimelineSeparator,
|
||||||
|
TimelineTitle,
|
||||||
|
} from '@/components/originui/timeline';
|
||||||
|
import { Aperture } from 'lucide-react';
|
||||||
|
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
date: '15 minutes ago',
|
||||||
|
title: 'Hannah Kandell',
|
||||||
|
action: 'opened a new issue',
|
||||||
|
description:
|
||||||
|
"I'm having trouble with the new component library. It's not rendering properly.",
|
||||||
|
image: '/avatar-40-01.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
date: '10 minutes ago',
|
||||||
|
title: 'Chris Tompson',
|
||||||
|
action: 'commented on',
|
||||||
|
description:
|
||||||
|
"Hey Hannah, I'm having trouble with the new component library. It's not rendering properly.",
|
||||||
|
image: '/avatar-40-02.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
date: '5 minutes ago',
|
||||||
|
title: 'Emma Davis',
|
||||||
|
action: 'assigned you to',
|
||||||
|
description:
|
||||||
|
'The new component library is not rendering properly. Can you take a look?',
|
||||||
|
image: '/avatar-40-03.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
date: '2 minutes ago',
|
||||||
|
title: 'Alex Morgan',
|
||||||
|
action: 'closed the issue',
|
||||||
|
description: 'The issue has been fixed. Please review the changes.',
|
||||||
|
image: '/avatar-40-05.jpg',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export function DataflowTimeline() {
|
export function DataflowTimeline() {
|
||||||
return <div>xx</div>;
|
return (
|
||||||
|
<Timeline>
|
||||||
|
{items.map((item) => (
|
||||||
|
<TimelineItem
|
||||||
|
key={item.id}
|
||||||
|
step={item.id}
|
||||||
|
className="group-data-[orientation=vertical]/timeline:ms-10 group-data-[orientation=vertical]/timeline:not-last:pb-8"
|
||||||
|
>
|
||||||
|
<TimelineHeader>
|
||||||
|
<TimelineSeparator className="group-data-[orientation=vertical]/timeline:-left-7 group-data-[orientation=vertical]/timeline:h-[calc(100%-1.5rem-0.25rem)] group-data-[orientation=vertical]/timeline:translate-y-7" />
|
||||||
|
<TimelineTitle className="">
|
||||||
|
{/* {item.title}
|
||||||
|
<span className="text-muted-foreground text-sm font-normal">
|
||||||
|
{item.action}
|
||||||
|
</span> */}
|
||||||
|
<TimelineContent className="text-foreground mt-2 rounded-lg border px-4 py-3">
|
||||||
|
{item.description}
|
||||||
|
<TimelineDate className="mt-1 mb-0">{item.date}</TimelineDate>
|
||||||
|
</TimelineContent>
|
||||||
|
</TimelineTitle>
|
||||||
|
<TimelineIndicator className="bg-primary/10 group-data-completed/timeline-item:bg-primary group-data-completed/timeline-item:text-primary-foreground flex size-6 items-center justify-center border-none group-data-[orientation=vertical]/timeline:-left-7">
|
||||||
|
<Aperture className="size-6 rounded-full" />
|
||||||
|
</TimelineIndicator>
|
||||||
|
</TimelineHeader>
|
||||||
|
{/* <TimelineContent className="text-foreground mt-2 rounded-lg border px-4 py-3">
|
||||||
|
{item.description}
|
||||||
|
<TimelineDate className="mt-1 mb-0">{item.date}</TimelineDate>
|
||||||
|
</TimelineContent> */}
|
||||||
|
</TimelineItem>
|
||||||
|
))}
|
||||||
|
</Timeline>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { IModalProps } from '@/interfaces/common';
|
|||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { NotebookText } from 'lucide-react';
|
import { NotebookText } from 'lucide-react';
|
||||||
import 'react18-json-view/src/style.css';
|
import 'react18-json-view/src/style.css';
|
||||||
|
import { DataflowTimeline } from './dataflow-timeline';
|
||||||
|
|
||||||
type LogSheetProps = IModalProps<any>;
|
type LogSheetProps = IModalProps<any>;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ export function LogSheet({ hideModal }: LogSheetProps) {
|
|||||||
<SheetHeader>
|
<SheetHeader>
|
||||||
<SheetTitle className="flex items-center gap-1">
|
<SheetTitle className="flex items-center gap-1">
|
||||||
<NotebookText className="size-4" />
|
<NotebookText className="size-4" />
|
||||||
Log
|
<DataflowTimeline></DataflowTimeline>
|
||||||
</SheetTitle>
|
</SheetTitle>
|
||||||
</SheetHeader>
|
</SheetHeader>
|
||||||
<section className="max-h-[82vh] overflow-auto mt-6"></section>
|
<section className="max-h-[82vh] overflow-auto mt-6"></section>
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import isObject from 'lodash/isObject';
|
|||||||
import {
|
import {
|
||||||
CategorizeAnchorPointPositions,
|
CategorizeAnchorPointPositions,
|
||||||
FileType,
|
FileType,
|
||||||
|
FileTypeSuffixMap,
|
||||||
NoDebugOperatorsList,
|
NoDebugOperatorsList,
|
||||||
NodeHandleId,
|
NodeHandleId,
|
||||||
Operator,
|
Operator,
|
||||||
@ -102,8 +103,11 @@ function transformParserParams(params: ParserFormSchemaType) {
|
|||||||
Record<string, ParserFormSchemaType['setups'][0]>
|
Record<string, ParserFormSchemaType['setups'][0]>
|
||||||
>((pre, cur) => {
|
>((pre, cur) => {
|
||||||
if (cur.fileFormat) {
|
if (cur.fileFormat) {
|
||||||
let filteredSetup: Partial<ParserFormSchemaType['setups'][0]> = {
|
let filteredSetup: Partial<
|
||||||
|
ParserFormSchemaType['setups'][0] & { suffix: string[] }
|
||||||
|
> = {
|
||||||
output_format: cur.output_format,
|
output_format: cur.output_format,
|
||||||
|
suffix: FileTypeSuffixMap[cur.fileFormat as FileType],
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (cur.fileFormat) {
|
switch (cur.fileFormat) {
|
||||||
|
|||||||
Reference in New Issue
Block a user