mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-24 07:26:47 +08:00
### What problem does this PR solve? Feat: Displaying the file option in the webhook's request body #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1030,3 +1030,10 @@ export enum WebhookSecurityAuthType {
|
|||||||
export const RateLimitPerList = ['minute', 'hour', 'day'];
|
export const RateLimitPerList = ['minute', 'hour', 'day'];
|
||||||
|
|
||||||
export const WebhookMaxBodySize = ['10MB', '50MB', '100MB', '1000MB'];
|
export const WebhookMaxBodySize = ['10MB', '50MB', '100MB', '1000MB'];
|
||||||
|
|
||||||
|
export enum WebhookRequestParameters {
|
||||||
|
File = VariableType.File,
|
||||||
|
String = TypesWithArray.String,
|
||||||
|
Number = TypesWithArray.Number,
|
||||||
|
Boolean = TypesWithArray.Boolean,
|
||||||
|
}
|
||||||
|
|||||||
@ -4,12 +4,13 @@ import { RAGFlowFormItem } from '@/components/ragflow-form';
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
import { Switch } from '@/components/ui/switch';
|
import { Switch } from '@/components/ui/switch';
|
||||||
|
import { buildOptions } from '@/utils/form';
|
||||||
import { loader } from '@monaco-editor/react';
|
import { loader } from '@monaco-editor/react';
|
||||||
|
import { omit } from 'lodash';
|
||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { useFieldArray, useFormContext } from 'react-hook-form';
|
import { useFieldArray, useFormContext } from 'react-hook-form';
|
||||||
import { TypesWithArray } from '../../../constant';
|
import { TypesWithArray, WebhookRequestParameters } from '../../../constant';
|
||||||
import { buildConversationVariableSelectOptions } from '../../../utils';
|
|
||||||
import { DynamicFormHeader } from '../../components/dynamic-fom-header';
|
import { DynamicFormHeader } from '../../components/dynamic-fom-header';
|
||||||
|
|
||||||
loader.config({ paths: { vs: '/vs' } });
|
loader.config({ paths: { vs: '/vs' } });
|
||||||
@ -22,9 +23,16 @@ type SelectKeysProps = {
|
|||||||
operatorField?: string;
|
operatorField?: string;
|
||||||
requiredField?: string;
|
requiredField?: string;
|
||||||
nodeId?: string;
|
nodeId?: string;
|
||||||
|
isObject?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const VariableTypeOptions = buildConversationVariableSelectOptions();
|
function buildParametersOptions(isObject: boolean) {
|
||||||
|
const list = isObject
|
||||||
|
? WebhookRequestParameters
|
||||||
|
: omit(WebhookRequestParameters, ['File']);
|
||||||
|
|
||||||
|
return buildOptions(list);
|
||||||
|
}
|
||||||
|
|
||||||
export function DynamicRequest({
|
export function DynamicRequest({
|
||||||
name,
|
name,
|
||||||
@ -33,6 +41,7 @@ export function DynamicRequest({
|
|||||||
keyField = 'key',
|
keyField = 'key',
|
||||||
operatorField = 'type',
|
operatorField = 'type',
|
||||||
requiredField = 'required',
|
requiredField = 'required',
|
||||||
|
isObject = false,
|
||||||
}: SelectKeysProps) {
|
}: SelectKeysProps) {
|
||||||
const form = useFormContext();
|
const form = useFormContext();
|
||||||
|
|
||||||
@ -75,7 +84,7 @@ export function DynamicRequest({
|
|||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
field.onChange(val);
|
field.onChange(val);
|
||||||
}}
|
}}
|
||||||
options={VariableTypeOptions}
|
options={buildParametersOptions(isObject)}
|
||||||
></SelectWithSearch>
|
></SelectWithSearch>
|
||||||
)}
|
)}
|
||||||
</RAGFlowFormItem>
|
</RAGFlowFormItem>
|
||||||
|
|||||||
@ -18,6 +18,7 @@ export function WebhookRequestSchema() {
|
|||||||
></DynamicRequest>
|
></DynamicRequest>
|
||||||
<DynamicRequest
|
<DynamicRequest
|
||||||
name="schema.body"
|
name="schema.body"
|
||||||
|
isObject
|
||||||
label={t('flow.webhook.requestBodyParameters')}
|
label={t('flow.webhook.requestBodyParameters')}
|
||||||
></DynamicRequest>
|
></DynamicRequest>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user