mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-25 16:26:51 +08:00
### What problem does this PR solve? Feat: Flatten the request schema of the webhook #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -35,7 +35,7 @@ import {
|
||||
Operator,
|
||||
TypesWithArray,
|
||||
} from './constant';
|
||||
import { BeginFormSchemaType } from './form/begin-form';
|
||||
import { BeginFormSchemaType } from './form/begin-form/schema';
|
||||
import { DataOperationsFormSchemaType } from './form/data-operations-form';
|
||||
import { ExtractorFormSchemaType } from './form/extractor-form';
|
||||
import { HierarchicalMergerFormSchemaType } from './form/hierarchical-merger-form';
|
||||
@ -326,10 +326,31 @@ export function transformArrayToObject(
|
||||
}, {});
|
||||
}
|
||||
|
||||
function transformRequestSchemaToJsonschema(
|
||||
schema: BeginFormSchemaType['schema'],
|
||||
) {
|
||||
const jsonSchema: Record<string, any> = {};
|
||||
Object.entries(schema || {}).forEach(([key, value]) => {
|
||||
if (Array.isArray(value)) {
|
||||
jsonSchema[key] = {
|
||||
type: 'object',
|
||||
required: value.filter((x) => x.required).map((x) => x.key),
|
||||
properties: value.reduce<Record<string, any>>((pre, cur) => {
|
||||
pre[cur.key] = { type: cur.type };
|
||||
return pre;
|
||||
}, {}),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return jsonSchema;
|
||||
}
|
||||
|
||||
function transformBeginParams(params: BeginFormSchemaType) {
|
||||
if (params.mode === AgentDialogueMode.Webhook) {
|
||||
return {
|
||||
...params,
|
||||
schema: transformRequestSchemaToJsonschema(params.schema),
|
||||
security: {
|
||||
...params.security,
|
||||
ip_whitelist: params.security?.ip_whitelist.map((x) => x.value),
|
||||
|
||||
Reference in New Issue
Block a user