Feat: Add a switch to control the display of structured output to the agent form. #10427 (#11344)

### 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:
balibabu
2025-11-18 18:58:36 +08:00
committed by GitHub
parent d1716d865a
commit 4942a23290
13 changed files with 133 additions and 75 deletions

View File

@ -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;
}