mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-22 14:16:42 +08:00
### What problem does this PR solve? Feat: Added the context operator form for data flow #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { ParseDocumentType } from '@/components/layout-recognize-form-field';
|
||||
import { initialLlmBaseValues } from '@/constants/agent';
|
||||
import {
|
||||
ChatVariableEnabledField,
|
||||
variableEnabledFieldMap,
|
||||
@ -15,6 +17,89 @@ import {
|
||||
WrapText,
|
||||
} from 'lucide-react';
|
||||
|
||||
export enum FileType {
|
||||
PDF = 'pdf',
|
||||
Spreadsheet = 'spreadsheet',
|
||||
Image = 'image',
|
||||
Email = 'email',
|
||||
TextMarkdown = 'text&markdown',
|
||||
Docx = 'word',
|
||||
PowerPoint = 'slides',
|
||||
Video = 'video',
|
||||
Audio = 'audio',
|
||||
}
|
||||
|
||||
export enum PdfOutputFormat {
|
||||
Json = 'json',
|
||||
Markdown = 'markdown',
|
||||
}
|
||||
|
||||
export enum SpreadsheetOutputFormat {
|
||||
Json = 'json',
|
||||
Html = 'html',
|
||||
}
|
||||
|
||||
export enum ImageOutputFormat {
|
||||
Text = 'text',
|
||||
}
|
||||
|
||||
export enum EmailOutputFormat {
|
||||
Json = 'json',
|
||||
Text = 'text',
|
||||
}
|
||||
|
||||
export enum TextMarkdownOutputFormat {
|
||||
Text = 'text',
|
||||
}
|
||||
|
||||
export enum DocxOutputFormat {
|
||||
Markdown = 'markdown',
|
||||
Json = 'json',
|
||||
}
|
||||
|
||||
export enum PptOutputFormat {
|
||||
Json = 'json',
|
||||
}
|
||||
|
||||
export enum VideoOutputFormat {
|
||||
Json = 'json',
|
||||
}
|
||||
|
||||
export enum AudioOutputFormat {
|
||||
Text = 'text',
|
||||
}
|
||||
|
||||
export const OutputFormatMap = {
|
||||
[FileType.PDF]: PdfOutputFormat,
|
||||
[FileType.Spreadsheet]: SpreadsheetOutputFormat,
|
||||
[FileType.Image]: ImageOutputFormat,
|
||||
[FileType.Email]: EmailOutputFormat,
|
||||
[FileType.TextMarkdown]: TextMarkdownOutputFormat,
|
||||
[FileType.Docx]: DocxOutputFormat,
|
||||
[FileType.PowerPoint]: PptOutputFormat,
|
||||
[FileType.Video]: VideoOutputFormat,
|
||||
[FileType.Audio]: AudioOutputFormat,
|
||||
};
|
||||
|
||||
export const InitialOutputFormatMap = {
|
||||
[FileType.PDF]: PdfOutputFormat.Json,
|
||||
[FileType.Spreadsheet]: SpreadsheetOutputFormat.Html,
|
||||
[FileType.Image]: ImageOutputFormat.Text,
|
||||
[FileType.Email]: EmailOutputFormat.Text,
|
||||
[FileType.TextMarkdown]: TextMarkdownOutputFormat.Text,
|
||||
[FileType.Docx]: DocxOutputFormat.Json,
|
||||
[FileType.PowerPoint]: PptOutputFormat.Json,
|
||||
[FileType.Video]: VideoOutputFormat.Json,
|
||||
[FileType.Audio]: AudioOutputFormat.Text,
|
||||
};
|
||||
|
||||
export enum ContextGeneratorFieldName {
|
||||
Summary = 'summary',
|
||||
Keywords = 'keywords',
|
||||
Questions = 'questions',
|
||||
Metadata = 'metadata',
|
||||
}
|
||||
|
||||
export enum PromptRole {
|
||||
User = 'user',
|
||||
Assistant = 'assistant',
|
||||
@ -83,9 +168,28 @@ export enum TokenizerFields {
|
||||
Summary = 'summary',
|
||||
}
|
||||
|
||||
export enum ParserFields {
|
||||
From = 'from',
|
||||
To = 'to',
|
||||
Cc = 'cc',
|
||||
Bcc = 'bcc',
|
||||
Date = 'date',
|
||||
Subject = 'subject',
|
||||
Body = 'body',
|
||||
Attachments = 'attachments',
|
||||
}
|
||||
|
||||
export const initialBeginValues = {
|
||||
mode: AgentDialogueMode.Conversational,
|
||||
prologue: `Hi! I'm your assistant. What can I do for you?`,
|
||||
outputs: {
|
||||
name: {
|
||||
type: 'string',
|
||||
value: '',
|
||||
},
|
||||
file: {
|
||||
type: 'Object',
|
||||
value: {},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const variableCheckBoxFieldMap = Object.keys(
|
||||
@ -125,10 +229,40 @@ export enum StringTransformDelimiter {
|
||||
Space = ' ',
|
||||
}
|
||||
|
||||
export const initialParserValues = { outputs: {}, setups: [] };
|
||||
export const initialParserValues = {
|
||||
outputs: {
|
||||
markdown: { type: 'string', value: '' },
|
||||
text: { type: 'string', value: '' },
|
||||
html: { type: 'string', value: '' },
|
||||
json: { type: 'Array<object>', value: [] },
|
||||
},
|
||||
setups: [
|
||||
{
|
||||
fileFormat: FileType.PDF,
|
||||
output_format: PdfOutputFormat.Json,
|
||||
parse_method: ParseDocumentType.DeepDOC,
|
||||
},
|
||||
{
|
||||
fileFormat: FileType.Spreadsheet,
|
||||
output_format: SpreadsheetOutputFormat.Html,
|
||||
},
|
||||
{
|
||||
fileFormat: FileType.Image,
|
||||
output_format: ImageOutputFormat.Text,
|
||||
parse_method: ImageParseMethod.OCR,
|
||||
},
|
||||
{
|
||||
fileFormat: FileType.Email,
|
||||
fields: Object.values(ParserFields),
|
||||
output_format: EmailOutputFormat.Text,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const initialSplitterValues = {
|
||||
outputs: {},
|
||||
outputs: {
|
||||
chunks: { type: 'Array<Object>', value: [] },
|
||||
},
|
||||
chunk_token_size: 512,
|
||||
overlapped_percent: 0,
|
||||
delimiters: [{ value: '\n' }],
|
||||
@ -143,7 +277,9 @@ export enum Hierarchy {
|
||||
}
|
||||
|
||||
export const initialHierarchicalMergerValues = {
|
||||
outputs: {},
|
||||
outputs: {
|
||||
chunks: { type: 'Array<Object>', value: [] },
|
||||
},
|
||||
hierarchy: Hierarchy.H3,
|
||||
levels: [
|
||||
{ expressions: [{ expression: '^#[^#]' }] },
|
||||
@ -154,6 +290,8 @@ export const initialHierarchicalMergerValues = {
|
||||
};
|
||||
|
||||
export const initialContextValues = {
|
||||
...initialLlmBaseValues,
|
||||
field_name: [ContextGeneratorFieldName.Summary],
|
||||
outputs: {},
|
||||
};
|
||||
|
||||
@ -232,18 +370,6 @@ export enum AgentExceptionMethod {
|
||||
Goto = 'goto',
|
||||
}
|
||||
|
||||
export enum FileType {
|
||||
PDF = 'pdf',
|
||||
Spreadsheet = 'spreadsheet',
|
||||
Image = 'image',
|
||||
Email = 'email',
|
||||
TextMarkdown = 'text&markdown',
|
||||
Docx = 'word',
|
||||
PowerPoint = 'slides',
|
||||
Video = 'video',
|
||||
Audio = 'audio',
|
||||
}
|
||||
|
||||
export const FileTypeSuffixMap = {
|
||||
[FileType.PDF]: ['pdf'],
|
||||
[FileType.Spreadsheet]: ['xls', 'xlsx', 'csv'],
|
||||
|
||||
Reference in New Issue
Block a user