Skip to content

Commit 0fcb168

Browse files
authored
Feat: Displaying the file option in the webhook's request body #10427 (#11928)
### 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)
1 parent 50715ba commit 0fcb168

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

web/src/pages/agent/constant/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,3 +1030,10 @@ export enum WebhookSecurityAuthType {
10301030
export const RateLimitPerList = ['minute', 'hour', 'day'];
10311031

10321032
export const WebhookMaxBodySize = ['10MB', '50MB', '100MB', '1000MB'];
1033+
1034+
export enum WebhookRequestParameters {
1035+
File = VariableType.File,
1036+
String = TypesWithArray.String,
1037+
Number = TypesWithArray.Number,
1038+
Boolean = TypesWithArray.Boolean,
1039+
}

web/src/pages/agent/form/begin-form/webhook/dynamic-request.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { RAGFlowFormItem } from '@/components/ragflow-form';
44
import { Button } from '@/components/ui/button';
55
import { Separator } from '@/components/ui/separator';
66
import { Switch } from '@/components/ui/switch';
7+
import { buildOptions } from '@/utils/form';
78
import { loader } from '@monaco-editor/react';
9+
import { omit } from 'lodash';
810
import { X } from 'lucide-react';
911
import { ReactNode } from 'react';
1012
import { useFieldArray, useFormContext } from 'react-hook-form';
11-
import { TypesWithArray } from '../../../constant';
12-
import { buildConversationVariableSelectOptions } from '../../../utils';
13+
import { TypesWithArray, WebhookRequestParameters } from '../../../constant';
1314
import { DynamicFormHeader } from '../../components/dynamic-fom-header';
1415

1516
loader.config({ paths: { vs: '/vs' } });
@@ -22,9 +23,16 @@ type SelectKeysProps = {
2223
operatorField?: string;
2324
requiredField?: string;
2425
nodeId?: string;
26+
isObject?: boolean;
2527
};
2628

27-
const VariableTypeOptions = buildConversationVariableSelectOptions();
29+
function buildParametersOptions(isObject: boolean) {
30+
const list = isObject
31+
? WebhookRequestParameters
32+
: omit(WebhookRequestParameters, ['File']);
33+
34+
return buildOptions(list);
35+
}
2836

2937
export function DynamicRequest({
3038
name,
@@ -33,6 +41,7 @@ export function DynamicRequest({
3341
keyField = 'key',
3442
operatorField = 'type',
3543
requiredField = 'required',
44+
isObject = false,
3645
}: SelectKeysProps) {
3746
const form = useFormContext();
3847

@@ -75,7 +84,7 @@ export function DynamicRequest({
7584
onChange={(val) => {
7685
field.onChange(val);
7786
}}
78-
options={VariableTypeOptions}
87+
options={buildParametersOptions(isObject)}
7988
></SelectWithSearch>
8089
)}
8190
</RAGFlowFormItem>

web/src/pages/agent/form/begin-form/webhook/request-schema.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function WebhookRequestSchema() {
1818
></DynamicRequest>
1919
<DynamicRequest
2020
name="schema.body"
21+
isObject
2122
label={t('flow.webhook.requestBodyParameters')}
2223
></DynamicRequest>
2324
</section>

0 commit comments

Comments
 (0)