feat: workflow support input json

This commit is contained in:
Joel 2025-08-22 14:54:34 +08:00
parent a1f278bdc8
commit e38ba8403d
3 changed files with 18 additions and 0 deletions

View File

@ -19,6 +19,8 @@ import { getProcessedFiles } from '@/app/components/base/file-uploader/utils'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import cn from '@/utils/classnames'
import BoolInput from '@/app/components/workflow/nodes/_base/components/before-run-form/bool-input'
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
export type IRunOnceProps = {
siteInfo: SiteInfo
@ -149,6 +151,18 @@ const RunOnce: FC<IRunOnceProps> = ({
}}
/>
)}
{item.type === 'json_object' && (
<CodeEditor
language={CodeLanguage.json}
value={inputs[item.key]}
onChange={(value) => { handleInputsChange({ ...inputsRef.current, [item.key]: value }) }}
noWrapper
className='bg h-[80px] overflow-y-auto rounded-[10px] bg-components-input-bg-normal p-1'
placeholder={
<div className='whitespace-pre'>{item.json_schema}</div>
}
/>
)}
</div>
</div>
))}

View File

@ -60,6 +60,7 @@ export type PromptVariable = {
icon?: string
icon_background?: string
hide?: boolean // used in frontend to hide variable
json_schema?: string
}
export type CompletionParams = {

View File

@ -30,6 +30,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
if (item.external_data_tool)
return [item.external_data_tool.type, item.external_data_tool]
if (item.json_object)
return ['json_object', item.json_object]
return ['select', item.select || {}]
})()
const is_context_var = dataset_query_variable === content?.variable