Ver código fonte

fix: stringify object while exporting batch result to csv (#3481)

sino 1 ano atrás
pai
commit
22994a6d14
1 arquivos alterados com 6 adições e 1 exclusões
  1. 6 1
      web/app/components/share/text-generation/index.tsx

+ 6 - 1
web/app/components/share/text-generation/index.tsx

@@ -174,7 +174,12 @@ const TextGeneration: FC<IMainProps> = ({
     promptConfig?.prompt_variables.forEach((v) => {
       res[v.name] = inputs[v.key]
     })
-    res[t('share.generation.completionResult')] = batchCompletionResLatest[task.id]
+    let result = batchCompletionResLatest[task.id]
+    // task might return multiple fields, should marshal object to string
+    if (typeof batchCompletionResLatest[task.id] === 'object')
+      result = JSON.stringify(result)
+
+    res[t('share.generation.completionResult')] = result
     return res
   })
   const checkBatchInputs = (data: string[][]) => {