Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array[string] 字符串数组的上限无法调整吗? #436

Open
1212wuhu opened this issue Jan 12, 2025 · 1 comment
Open

Array[string] 字符串数组的上限无法调整吗? #436

1212wuhu opened this issue Jan 12, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@1212wuhu
Copy link

我在执行“代码执行”节点时,意外发现传入Array[string] 输出变量的数组超过30就无法执行。请问有什么扩充的方法吗?
我执行的代码:

def main(text: str) -> dict:
    lines = text.split('\n')
    chunks = [lines[i:i + 10] for i in range(0, len(lines), 10)]
    chunks = ['\n'.join(chunk) for chunk in chunks]
    return {'result': chunks}

报错:

The length of output variable result must be less than 30 elements.

修改切片大小后恢复正常,但这样造成了每个切片长度过大,想问下有没有可以提升Array[string] 字符串数组的上限设定呢?

Copy link

dosubot bot commented Jan 12, 2025

Hello, @1212wuhu! I'm here to help you with any coding issues or questions you may have. I'm an expert at solving bugs and answering technical questions. Let me know how I can assist you!

在 dify-docs 中,您可以通过使用迭代节点来处理或分块处理大型数组,以绕过 30 元素的限制。迭代节点允许您将数据拆分为较小的块,并分别处理每个块。这对于批处理或翻译等任务特别有用,您可能会遇到一次可以处理的元素数量限制。

以下是如何使用迭代节点的方法:

  1. 输入变量: 迭代节点接受格式化为列表对象(数组)的输入值。
  2. 迭代工作流: 您可以定义要应用于数组中每个元素的任务序列。
  3. 输出变量: 节点输出数组变量,与输入保持一对一的对应关系。

此外,Dify 支持并行处理,允许最多 10 个并发迭代。这意味着在处理超过 10 个任务时,前 10 个元素同时执行,剩余任务在初始批次完成后处理。这可以显著提高处理大型数据集的效率。

通过这种方法,您可以将大型数据集分解为可管理的部分进行处理,同时确保稳健的错误处理[1][2][3]

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the bug Something isn't working label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant