mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 00:46:52 +08:00
### What problem does this PR solve? Feat: Add a switch to control the display of structured output to the agent form. #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,9 +1,13 @@
|
||||
import { JSONSchema } from '@/components/jsonjoy-builder';
|
||||
import { getStructuredDatatype } from '@/utils/canvas-util';
|
||||
import { get, isPlainObject, toLower } from 'lodash';
|
||||
import { JsonSchemaDataType } from '../constant';
|
||||
|
||||
function predicate(types: string[], type: string) {
|
||||
return types.some((x) => toLower(x) === toLower(type));
|
||||
function predicate(types: string[], value: unknown) {
|
||||
return types.some(
|
||||
(x) =>
|
||||
toLower(x) === toLower(getStructuredDatatype(value).compositeDataType),
|
||||
);
|
||||
}
|
||||
|
||||
export function hasSpecificTypeChild(
|
||||
@ -12,7 +16,7 @@ export function hasSpecificTypeChild(
|
||||
) {
|
||||
if (Array.isArray(data)) {
|
||||
for (const value of data) {
|
||||
if (isPlainObject(value) && predicate(types, value.type)) {
|
||||
if (isPlainObject(value) && predicate(types, value)) {
|
||||
return true;
|
||||
}
|
||||
if (hasSpecificTypeChild(value, types)) {
|
||||
@ -23,7 +27,11 @@ export function hasSpecificTypeChild(
|
||||
|
||||
if (isPlainObject(data)) {
|
||||
for (const value of Object.values(data)) {
|
||||
if (isPlainObject(value) && predicate(types, value.type)) {
|
||||
if (
|
||||
isPlainObject(value) &&
|
||||
predicate(types, value) &&
|
||||
get(data, 'type') !== JsonSchemaDataType.Array
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user