mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-25 07:38:15 +08:00
Fix: optional input in batch run (#19257)
This commit is contained in:
parent
b979a8a707
commit
4b77c9df9d
@ -302,10 +302,17 @@ const TextGeneration: FC<IMainProps> = ({
|
|||||||
const varLen = promptConfig?.prompt_variables.length || 0
|
const varLen = promptConfig?.prompt_variables.length || 0
|
||||||
setIsCallBatchAPI(true)
|
setIsCallBatchAPI(true)
|
||||||
const allTaskList: Task[] = payloadData.map((item, i) => {
|
const allTaskList: Task[] = payloadData.map((item, i) => {
|
||||||
const inputs: Record<string, string> = {}
|
const inputs: Record<string, any> = {}
|
||||||
if (varLen > 0) {
|
if (varLen > 0) {
|
||||||
item.slice(0, varLen).forEach((input, index) => {
|
item.slice(0, varLen).forEach((input, index) => {
|
||||||
inputs[promptConfig?.prompt_variables[index].key as string] = input
|
const varSchema = promptConfig?.prompt_variables[index]
|
||||||
|
inputs[varSchema?.key as string] = input
|
||||||
|
if (!input) {
|
||||||
|
if (varSchema?.type === 'string' || varSchema?.type === 'paragraph')
|
||||||
|
inputs[varSchema?.key as string] = ''
|
||||||
|
else
|
||||||
|
inputs[varSchema?.key as string] = undefined
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -45,7 +45,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
|||||||
const onClear = () => {
|
const onClear = () => {
|
||||||
const newInputs: Record<string, any> = {}
|
const newInputs: Record<string, any> = {}
|
||||||
promptConfig.prompt_variables.forEach((item) => {
|
promptConfig.prompt_variables.forEach((item) => {
|
||||||
if (item.type === 'text-input' || item.type === 'paragraph')
|
if (item.type === 'string' || item.type === 'paragraph')
|
||||||
newInputs[item.key] = ''
|
newInputs[item.key] = ''
|
||||||
else
|
else
|
||||||
newInputs[item.key] = undefined
|
newInputs[item.key] = undefined
|
||||||
@ -66,7 +66,7 @@ const RunOnce: FC<IRunOnceProps> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const newInputs: Record<string, any> = {}
|
const newInputs: Record<string, any> = {}
|
||||||
promptConfig.prompt_variables.forEach((item) => {
|
promptConfig.prompt_variables.forEach((item) => {
|
||||||
if (item.type === 'text-input' || item.type === 'paragraph')
|
if (item.type === 'string' || item.type === 'paragraph')
|
||||||
newInputs[item.key] = ''
|
newInputs[item.key] = ''
|
||||||
else
|
else
|
||||||
newInputs[item.key] = undefined
|
newInputs[item.key] = undefined
|
||||||
|
Loading…
x
Reference in New Issue
Block a user