From 6f82ad304b37550c35ec252b7d5e28a449e74b34 Mon Sep 17 00:00:00 2001 From: AllenWriter Date: Wed, 23 Apr 2025 10:38:13 +0800 Subject: [PATCH] Docs: sync docs 4.22 --- conversion.log | 7 + docs.json | 50 +- en/community/contribution.mdx | 2 +- .../models-integration/gpustack.mdx | 11 +- en/getting-started/cloud.mdx | 2 +- en/getting-started/dify-for-education.mdx | 167 +++ en/getting-started/dify-premium.mdx | 4 + .../install-self-hosted/environments.mdx | 9 +- .../install-self-hosted/faqs.mdx | 22 +- .../install-self-hosted/local-source-code.mdx | 3 +- en/getting-started/readme/model-providers.mdx | 8 + .../creating-an-application.mdx | 2 +- .../launch-your-webapp-quickly/README.mdx | 2 +- .../external-knowledge-api-documentation.mdx | 53 +- .../connect-external-knowledge-base.mdx | 34 +- .../knowledge-base/external-knowledge-api.mdx | 15 +- .../maintain-dataset-via-api.mdx | 4 +- .../sync-from-website.mdx | 4 +- .../knowledge-request-rate-limit.mdx | 42 + en/guides/management/version-control.mdx | 8 +- en/guides/workflow/node/agent.mdx | 9 +- en/guides/workflow/node/loop.mdx | 78 +- en/guides/workflow/node/template.mdx | 35 +- en/guides/workflow/nodes/README.mdx | 10 - en/guides/workflow/nodes/agent.mdx | 78 -- en/guides/workflow/nodes/answer.mdx | 31 - en/guides/workflow/nodes/code.mdx | 122 -- en/guides/workflow/nodes/doc-extractor.mdx | 65 - en/guides/workflow/nodes/end.mdx | 32 - en/guides/workflow/nodes/http-request.mdx | 65 - en/guides/workflow/nodes/ifelse.mdx | 47 - en/guides/workflow/nodes/iteration.mdx | 186 --- .../workflow/nodes/knowledge-retrieval.mdx | 41 - en/guides/workflow/nodes/list-operator.mdx | 80 -- en/guides/workflow/nodes/llm.mdx | 177 --- en/guides/workflow/nodes/loop.mdx | 85 -- .../workflow/nodes/parameter-extractor.mdx | 61 - .../workflow/nodes/question-classifier.mdx | 57 - en/guides/workflow/nodes/start.mdx | 150 --- en/guides/workflow/nodes/template.mdx | 32 - en/guides/workflow/nodes/tools.mdx | 64 - .../workflow/nodes/variable-aggregator.mdx | 42 - .../workflow/nodes/variable-assigner.mdx | 183 --- en/guides/workflow/shortcut-key.mdx | 12 +- .../build-an-notion-ai-assistant copy.mdx | 167 +++ .../building-an-ai-thesis-slack-bot.mdx | 1 - ...-chatbot-with-business-data-in-minutes.mdx | 2 +- .../private-ai-ollama-deepseek-dify.mdx | 4 +- .../best-practice/how-to-use-mcp-zapier.mdx | 129 ++ en/plugins/introduction.mdx | 4 +- en/plugins/publish-plugins/README.mdx | 5 +- .../package-plugin-file-and-publish.mdx | 1 - .../plugin-auto-publish-pr.mdx | 298 +++++ ...for-third-party-signature-verification.mdx | 96 ++ en/plugins/quick-start/debug-plugin.mdx | 2 +- .../quick-start/develop-plugins/README.mdx | 2 +- .../develop-plugins/agent-strategy-plugin.mdx | 201 ++- .../quick-start/develop-plugins/bundle.mdx | 2 +- .../model-plugin/customizable-model.mdx | 4 +- .../develop-plugins/tool-plugin.mdx | 2 +- en/plugins/quick-start/install-plugins.mdx | 14 +- en/plugins/schema-definition/manifest.mdx | 6 +- .../models-integration/gpustack.mdx | 9 +- ja-jp/getting-started/cloud.mdx | 34 +- ja-jp/getting-started/dify-for-education.mdx | 171 +++ ja-jp/getting-started/dify-premium.mdx | 4 + .../install-self-hosted/environments.mdx | 9 +- .../install-self-hosted/faq.mdx | 22 +- .../install-self-hosted/local-source-code.mdx | 4 +- .../readme/model-providers.mdx | 10 +- .../app-toolkits/moderation-tool.mdx | 9 +- .../external-knowledge-api-documentation.mdx | 16 + .../connect-external-knowledge-base.mdx | 34 + .../connect-external-knowledge-base.mdx.bak | 123 -- .../readme.mdx | 4 +- ja-jp/guides/knowledge-base/faq.mdx.bak | 20 - ...grate-knowledge-within-application.mdx.bak | 204 ---- ...nowledge-and-documents-maintenance.mdx.bak | 134 -- .../introduction.mdx | 48 - .../introduction.mdx.bak | 48 - .../maintain-dataset-via-api.mdx | 222 ++-- .../maintain-knowledge-documents.mdx.bak | 133 -- .../readme.mdx | 96 ++ .../knowledge-request-rate-limit.mdx | 40 + ja-jp/guides/knowledge-base/metadata.mdx | 527 ++++---- ja-jp/guides/knowledge-base/metadata.mdx.bak | 409 ------- ja-jp/guides/knowledge-base/readme.mdx.bak | 39 - .../retrieval-test-and-citation.md | 68 ++ .../retrieval-test-and-citation.mdx | 11 +- .../workflow/additional-feature.mdx.bak | 110 -- .../workflow/application-publishing.mdx.bak | 25 - ja-jp/guides/workflow/bulletin.mdx.bak | 131 -- ja-jp/guides/workflow/concepts.mdx.bak | 34 - ja-jp/guides/workflow/file-upload.mdx.bak | 201 --- ja-jp/guides/workflow/node/agent.mdx | 12 +- ja-jp/guides/workflow/node/code.mdx.bak | 94 -- .../workflow/node/doc-extractor.mdx.bak | 67 - ja-jp/guides/workflow/node/end.mdx.bak | 30 - .../workflow/node/knowledge-retrieval.mdx.bak | 59 - .../workflow/node/list-operator.mdx.bak | 93 -- ja-jp/guides/workflow/node/llm.mdx.bak | 156 --- ja-jp/guides/workflow/node/loop.mdx | 94 +- ja-jp/guides/workflow/node/loop.mdx.bak | 135 ++ .../workflow/node/parameter-extractor.mdx.bak | 73 -- .../workflow/node/question-classifier.mdx.bak | 65 - ja-jp/guides/workflow/node/start.mdx.bak | 88 -- ja-jp/guides/workflow/node/template.mdx | 48 +- ja-jp/guides/workflow/node/tools.mdx.bak | 32 - .../workflow/node/variable-assigner.mdx.bak | 169 --- ja-jp/guides/workflow/nodes/README.mdx | 7 - ja-jp/guides/workflow/nodes/agent.mdx | 99 -- ja-jp/guides/workflow/nodes/answer.mdx | 19 - ja-jp/guides/workflow/nodes/code.mdx | 94 -- ja-jp/guides/workflow/nodes/code.mdx.bak | 94 -- ja-jp/guides/workflow/nodes/doc-extractor.mdx | 67 - .../workflow/nodes/doc-extractor.mdx.bak | 67 - ja-jp/guides/workflow/nodes/end.mdx | 30 - ja-jp/guides/workflow/nodes/end.mdx.bak | 30 - ja-jp/guides/workflow/nodes/http-request.mdx | 36 - ja-jp/guides/workflow/nodes/ifelse.mdx | 55 - ja-jp/guides/workflow/nodes/iteration.mdx | 189 --- .../workflow/nodes/knowledge-retrieval.mdx | 59 - .../nodes/knowledge-retrieval.mdx.bak | 59 - ja-jp/guides/workflow/nodes/list-operator.mdx | 93 -- .../workflow/nodes/list-operator.mdx.bak | 93 -- ja-jp/guides/workflow/nodes/llm.mdx | 156 --- ja-jp/guides/workflow/nodes/llm.mdx.bak | 156 --- ja-jp/guides/workflow/nodes/loop.mdx | 91 -- .../workflow/nodes/parameter-extractor.mdx | 73 -- .../nodes/parameter-extractor.mdx.bak | 73 -- .../workflow/nodes/question-classifier.mdx | 65 - .../nodes/question-classifier.mdx.bak | 65 - ja-jp/guides/workflow/nodes/start.mdx | 88 -- ja-jp/guides/workflow/nodes/start.mdx.bak | 88 -- ja-jp/guides/workflow/nodes/template.mdx | 48 - ja-jp/guides/workflow/nodes/tools.mdx | 32 - ja-jp/guides/workflow/nodes/tools.mdx.bak | 32 - .../workflow/nodes/variable-aggregator.mdx | 45 - .../workflow/nodes/variable-assigner.mdx | 169 --- .../workflow/nodes/variable-assigner.mdx.bak | 169 --- ja-jp/guides/workflow/publish.mdx.bak | 24 - ja-jp/guides/workflow/variables.mdx.bak | 186 --- .../building-an-ai-thesis-slack-bot.mdx | 1 - .../develop-a-slack-bot-plugin.mdx | 1 - .../develop-a-slack-bot-plugin.mdx.bak | 331 ----- .../best-practice/how-to-use-mcp-zapier.mdx | 127 ++ ja-jp/plugins/publish-plugins/README.mdx | 2 + ja-jp/plugins/publish-plugins/README.mdx.bak | 67 - .../package-plugin-file-and-publish.mdx.bak | 43 - .../plugin-auto-publish-pr.mdx | 296 +++++ ...ish-plugin-on-personal-github-repo.mdx.bak | 87 -- ...for-third-party-signature-verification.mdx | 96 ++ ja-jp/plugins/quick-start/debug-plugin.mdx | 6 +- .../develop-plugins/agent-strategy-plugin.mdx | 176 ++- .../agent-strategy-plugin.mdx.bak | 1082 ----------------- .../quick-start/develop-plugins/bundle.mdx | 2 +- .../model-plugin/customizable-model.mdx | 4 +- .../develop-plugins/tool-plugin.mdx | 2 +- ja-jp/plugins/schema-definition/manifest.mdx | 6 +- .../schema-definition/manifest.mdx.bak | 2 +- scripts/convert_gitbook_to_mintlify.py | 79 ++ scripts/high-light-convert-4.22.py | 133 ++ scripts/high-light-convert.py | 170 +++ zh-hans/community/contribution.mdx | 2 +- .../development/backend/sandbox/README.mdx | 2 +- .../development/migration/migrate-to-v1.mdx | 15 +- .../models-integration/gpustack.mdx | 11 +- zh-hans/getting-started/cloud.mdx | 33 +- .../getting-started/dify-for-education.mdx | 173 +++ zh-hans/getting-started/dify-premium.mdx | 4 + .../install-self-hosted/environments.mdx | 12 +- .../install-self-hosted/faq.mdx | 24 +- .../install-self-hosted/local-source-code.mdx | 4 +- .../readme/model-providers.mdx | 8 + .../guides/annotation/annotation-reply.mdx | 2 +- .../guides/application-orchestrate/agent.mdx | 1 - .../chatbot-application.mdx | 2 +- .../creating-an-application.mdx | 4 +- .../guides/application-orchestrate/readme.mdx | 2 +- .../based-on-frontend-templates.mdx | 8 +- .../developing-with-apis.mdx | 2 +- .../text-generator.mdx | 4 +- .../external-knowledge-api-documentation.mdx | 16 +- .../connect-external-knowledge-base.mdx | 28 +- .../maintain-dataset-via-api.mdx | 4 +- zh-hans/guides/management/version-control.mdx | 2 +- .../guides/monitoring/annotation-reply.mdx | 2 +- .../api-based/cloudflare-workers.mdx | 29 +- .../tools/extensions/api-based/moderation.mdx | 116 +- .../code-based/external-data-tool.mdx | 4 +- .../extensions/code-based/moderation.mdx | 4 +- .../tools/tool-configuration/searxng.mdx | 31 +- zh-hans/guides/workflow/file-upload.mdx | 8 - zh-hans/guides/workflow/node/agent.mdx | 8 + zh-hans/guides/workflow/node/llm.mdx | 2 +- zh-hans/guides/workflow/node/loop.mdx | 92 +- .../workflow/node/parameter-extractor.mdx | 2 +- zh-hans/guides/workflow/node/template.mdx | 31 +- zh-hans/guides/workflow/nodes/README.mdx | 7 - zh-hans/guides/workflow/nodes/agent.mdx | 73 -- zh-hans/guides/workflow/nodes/answer.mdx | 21 - zh-hans/guides/workflow/nodes/code.mdx | 122 -- .../guides/workflow/nodes/doc-extractor.mdx | 65 - zh-hans/guides/workflow/nodes/end.mdx | 31 - .../guides/workflow/nodes/http-request.mdx | 63 - zh-hans/guides/workflow/nodes/ifelse.mdx | 50 - zh-hans/guides/workflow/nodes/iteration.mdx | 175 --- .../workflow/nodes/knowledge-retrieval.mdx | 53 - .../guides/workflow/nodes/list-operator.mdx | 88 -- zh-hans/guides/workflow/nodes/llm.mdx | 158 --- zh-hans/guides/workflow/nodes/loop.mdx | 89 -- .../workflow/nodes/parameter-extractor.mdx | 66 - .../workflow/nodes/question-classifier.mdx | 58 - zh-hans/guides/workflow/nodes/start.mdx | 70 -- zh-hans/guides/workflow/nodes/template.mdx | 48 - zh-hans/guides/workflow/nodes/tools.mdx | 56 - .../workflow/nodes/variable-aggregator.mdx | 45 - .../workflow/nodes/variable-assigner.mdx | 167 --- zh-hans/guides/workflow/shortcut-key.mdx | 2 +- zh-hans/guides/workspace/app.mdx | 8 +- zh-hans/guides/workspace/readme.mdx | 14 +- .../prompt-engineering-1/README.mdx | 9 +- .../prompt-engineering-template.mdx | 14 +- zh-hans/learn-more/faq/plugins.mdx | 2 + .../building-an-ai-thesis-slack-bot.mdx | 136 +++ ...ious-im-platforms-by-using-langbot.mdx.mdx | 105 ++ .../learn-more/use-cases/dify-on-dingtalk.mdx | 6 +- .../learn-more/use-cases/dify-on-wechat.mdx | 204 ++-- .../best-practice/how-to-use-mcp-zapier.mdx | 129 ++ zh-hans/plugins/publish-plugins/README.mdx | 2 + .../package-plugin-file-and-publish.mdx | 1 - .../plugin-auto-publish-pr.mdx | 297 +++++ ...ish-plugin-on-personal-github-repo.mdx.bak | 92 -- ...for-third-party-signature-verification.mdx | 100 ++ zh-hans/plugins/quick-start/debug-plugin.mdx | 4 +- .../develop-plugins/agent-strategy-plugin.mdx | 174 ++- .../model-plugin/customizable-model.mdx | 2 +- .../develop-plugins/tool-plugin.mdx | 4 +- .../plugins/schema-definition/manifest.mdx | 6 +- .../model.mdx | 20 +- zh-hans/url-report/link-check-report.md | 2 +- 241 files changed, 5218 insertions(+), 10971 deletions(-) create mode 100644 en/getting-started/dify-for-education.mdx create mode 100644 en/guides/knowledge-base/knowledge-request-rate-limit.mdx delete mode 100644 en/guides/workflow/nodes/README.mdx delete mode 100644 en/guides/workflow/nodes/agent.mdx delete mode 100644 en/guides/workflow/nodes/answer.mdx delete mode 100644 en/guides/workflow/nodes/code.mdx delete mode 100644 en/guides/workflow/nodes/doc-extractor.mdx delete mode 100644 en/guides/workflow/nodes/end.mdx delete mode 100644 en/guides/workflow/nodes/http-request.mdx delete mode 100644 en/guides/workflow/nodes/ifelse.mdx delete mode 100644 en/guides/workflow/nodes/iteration.mdx delete mode 100644 en/guides/workflow/nodes/knowledge-retrieval.mdx delete mode 100644 en/guides/workflow/nodes/list-operator.mdx delete mode 100644 en/guides/workflow/nodes/llm.mdx delete mode 100644 en/guides/workflow/nodes/loop.mdx delete mode 100644 en/guides/workflow/nodes/parameter-extractor.mdx delete mode 100644 en/guides/workflow/nodes/question-classifier.mdx delete mode 100644 en/guides/workflow/nodes/start.mdx delete mode 100644 en/guides/workflow/nodes/template.mdx delete mode 100644 en/guides/workflow/nodes/tools.mdx delete mode 100644 en/guides/workflow/nodes/variable-aggregator.mdx delete mode 100644 en/guides/workflow/nodes/variable-assigner.mdx create mode 100644 en/learn-more/use-cases/build-an-notion-ai-assistant copy.mdx create mode 100644 en/plugins/best-practice/how-to-use-mcp-zapier.mdx create mode 100644 en/plugins/publish-plugins/plugin-auto-publish-pr.mdx create mode 100644 en/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification.mdx create mode 100644 ja-jp/getting-started/dify-for-education.mdx delete mode 100644 ja-jp/guides/knowledge-base/connect-external-knowledge-base.mdx.bak delete mode 100644 ja-jp/guides/knowledge-base/faq.mdx.bak delete mode 100644 ja-jp/guides/knowledge-base/integrate-knowledge-within-application.mdx.bak delete mode 100644 ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance.mdx.bak delete mode 100644 ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx delete mode 100644 ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx.bak delete mode 100644 ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx.bak create mode 100644 ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/readme.mdx create mode 100644 ja-jp/guides/knowledge-base/knowledge-request-rate-limit.mdx delete mode 100644 ja-jp/guides/knowledge-base/metadata.mdx.bak delete mode 100644 ja-jp/guides/knowledge-base/readme.mdx.bak create mode 100644 ja-jp/guides/knowledge-base/retrieval-test-and-citation.md delete mode 100644 ja-jp/guides/workflow/additional-feature.mdx.bak delete mode 100644 ja-jp/guides/workflow/application-publishing.mdx.bak delete mode 100644 ja-jp/guides/workflow/bulletin.mdx.bak delete mode 100644 ja-jp/guides/workflow/concepts.mdx.bak delete mode 100644 ja-jp/guides/workflow/file-upload.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/code.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/doc-extractor.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/end.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/knowledge-retrieval.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/list-operator.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/llm.mdx.bak create mode 100644 ja-jp/guides/workflow/node/loop.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/parameter-extractor.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/question-classifier.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/start.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/tools.mdx.bak delete mode 100644 ja-jp/guides/workflow/node/variable-assigner.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/README.mdx delete mode 100644 ja-jp/guides/workflow/nodes/agent.mdx delete mode 100644 ja-jp/guides/workflow/nodes/answer.mdx delete mode 100644 ja-jp/guides/workflow/nodes/code.mdx delete mode 100644 ja-jp/guides/workflow/nodes/code.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/doc-extractor.mdx delete mode 100644 ja-jp/guides/workflow/nodes/doc-extractor.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/end.mdx delete mode 100644 ja-jp/guides/workflow/nodes/end.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/http-request.mdx delete mode 100644 ja-jp/guides/workflow/nodes/ifelse.mdx delete mode 100644 ja-jp/guides/workflow/nodes/iteration.mdx delete mode 100644 ja-jp/guides/workflow/nodes/knowledge-retrieval.mdx delete mode 100644 ja-jp/guides/workflow/nodes/knowledge-retrieval.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/list-operator.mdx delete mode 100644 ja-jp/guides/workflow/nodes/list-operator.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/llm.mdx delete mode 100644 ja-jp/guides/workflow/nodes/llm.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/loop.mdx delete mode 100644 ja-jp/guides/workflow/nodes/parameter-extractor.mdx delete mode 100644 ja-jp/guides/workflow/nodes/parameter-extractor.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/question-classifier.mdx delete mode 100644 ja-jp/guides/workflow/nodes/question-classifier.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/start.mdx delete mode 100644 ja-jp/guides/workflow/nodes/start.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/template.mdx delete mode 100644 ja-jp/guides/workflow/nodes/tools.mdx delete mode 100644 ja-jp/guides/workflow/nodes/tools.mdx.bak delete mode 100644 ja-jp/guides/workflow/nodes/variable-aggregator.mdx delete mode 100644 ja-jp/guides/workflow/nodes/variable-assigner.mdx delete mode 100644 ja-jp/guides/workflow/nodes/variable-assigner.mdx.bak delete mode 100644 ja-jp/guides/workflow/publish.mdx.bak delete mode 100644 ja-jp/guides/workflow/variables.mdx.bak delete mode 100644 ja-jp/plugins/best-practice/develop-a-slack-bot-plugin.mdx.bak create mode 100644 ja-jp/plugins/best-practice/how-to-use-mcp-zapier.mdx delete mode 100644 ja-jp/plugins/publish-plugins/README.mdx.bak delete mode 100644 ja-jp/plugins/publish-plugins/package-plugin-file-and-publish.mdx.bak create mode 100644 ja-jp/plugins/publish-plugins/plugin-auto-publish-pr.mdx delete mode 100644 ja-jp/plugins/publish-plugins/publish-plugin-on-personal-github-repo.mdx.bak create mode 100644 ja-jp/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification.mdx delete mode 100644 ja-jp/plugins/quick-start/develop-plugins/agent-strategy-plugin.mdx.bak create mode 100644 scripts/convert_gitbook_to_mintlify.py create mode 100644 scripts/high-light-convert-4.22.py create mode 100644 scripts/high-light-convert.py create mode 100644 zh-hans/getting-started/dify-for-education.mdx delete mode 100644 zh-hans/guides/workflow/nodes/README.mdx delete mode 100644 zh-hans/guides/workflow/nodes/agent.mdx delete mode 100644 zh-hans/guides/workflow/nodes/answer.mdx delete mode 100644 zh-hans/guides/workflow/nodes/code.mdx delete mode 100644 zh-hans/guides/workflow/nodes/doc-extractor.mdx delete mode 100644 zh-hans/guides/workflow/nodes/end.mdx delete mode 100644 zh-hans/guides/workflow/nodes/http-request.mdx delete mode 100644 zh-hans/guides/workflow/nodes/ifelse.mdx delete mode 100644 zh-hans/guides/workflow/nodes/iteration.mdx delete mode 100644 zh-hans/guides/workflow/nodes/knowledge-retrieval.mdx delete mode 100644 zh-hans/guides/workflow/nodes/list-operator.mdx delete mode 100644 zh-hans/guides/workflow/nodes/llm.mdx delete mode 100644 zh-hans/guides/workflow/nodes/loop.mdx delete mode 100644 zh-hans/guides/workflow/nodes/parameter-extractor.mdx delete mode 100644 zh-hans/guides/workflow/nodes/question-classifier.mdx delete mode 100644 zh-hans/guides/workflow/nodes/start.mdx delete mode 100644 zh-hans/guides/workflow/nodes/template.mdx delete mode 100644 zh-hans/guides/workflow/nodes/tools.mdx delete mode 100644 zh-hans/guides/workflow/nodes/variable-aggregator.mdx delete mode 100644 zh-hans/guides/workflow/nodes/variable-assigner.mdx create mode 100644 zh-hans/learn-more/use-cases/building-an-ai-thesis-slack-bot.mdx create mode 100644 zh-hans/learn-more/use-cases/connect-dify-to-various-im-platforms-by-using-langbot.mdx.mdx create mode 100644 zh-hans/plugins/best-practice/how-to-use-mcp-zapier.mdx create mode 100644 zh-hans/plugins/publish-plugins/plugin-auto-publish-pr.mdx delete mode 100644 zh-hans/plugins/publish-plugins/publish-plugin-on-personal-github-repo.mdx.bak create mode 100644 zh-hans/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification.mdx diff --git a/conversion.log b/conversion.log index d8a08540..1f2a26c9 100644 --- a/conversion.log +++ b/conversion.log @@ -1,3 +1,10 @@ 2025-03-31 11:58:54,955 - md-to-mdx - INFO - 处理文件: zh-hans/guides/monitoring/integrate-external-ops-tools/integrate-opik.md 2025-03-31 11:58:54,964 - md-to-mdx - INFO - 转换完成: zh-hans/guides/monitoring/integrate-external-ops-tools/integrate-opik.mdx 2025-03-31 11:58:54,964 - md-to-mdx - INFO - 已删除源文件: zh-hans/guides/monitoring/integrate-external-ops-tools/integrate-opik.md +2025-04-22 13:56:11,988 - md-to-mdx - ERROR - 无效的输入路径: ja-jp/guides/knowledge-base/metadata.mdx +2025-04-22 13:57:34,348 - md-to-mdx - INFO - 处理文件: ja-jp/guides/knowledge-base/metadata.md +2025-04-22 13:57:34,372 - md-to-mdx - INFO - 转换完成: ja-jp/guides/knowledge-base/metadata.mdx +2025-04-22 13:57:34,372 - md-to-mdx - INFO - 已删除源文件: ja-jp/guides/knowledge-base/metadata.md +2025-04-22 14:03:25,635 - md-to-mdx - INFO - 处理文件: ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/readme.md +2025-04-22 14:03:25,646 - md-to-mdx - INFO - 转换完成: ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/readme.mdx +2025-04-22 14:03:25,647 - md-to-mdx - INFO - 已删除源文件: ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/readme.md diff --git a/docs.json b/docs.json index 623e581d..ced4ba93 100644 --- a/docs.json +++ b/docs.json @@ -45,7 +45,8 @@ ] }, "en/getting-started/cloud", - "en/getting-started/dify-premium" + "en/getting-started/dify-premium", + "en/getting-started/dify-for-education" ] }, { @@ -166,6 +167,7 @@ "en/guides/knowledge-base/metadata", "en/guides/knowledge-base/integrate-knowledge-within-application", "en/guides/knowledge-base/retrieval-test-and-citation", + "en/guides/knowledge-base/knowledge-request-rate-limit", "en/guides/knowledge-base/connect-external-knowledge-base", "en/guides/knowledge-base/external-knowledge-api" ] @@ -320,13 +322,15 @@ "group": "Best Practice", "pages": [ "en/plugins/best-practice/README", - "en/plugins/best-practice/develop-a-slack-bot-plugin" + "en/plugins/best-practice/develop-a-slack-bot-plugin", + "en/plugins/best-practice/how-to-use-mcp-zapier" ] }, { "group": "Publish Plugins", "pages": [ "en/plugins/publish-plugins/README", + "en/plugins/publish-plugins/plugin-auto-publish-pr", { "group": "Publish to Dify Marketplace", "pages": [ @@ -336,7 +340,8 @@ ] }, "en/plugins/publish-plugins/publish-plugin-on-personal-github-repo", - "en/plugins/publish-plugins/package-plugin-file-and-publish" + "en/plugins/publish-plugins/package-plugin-file-and-publish", + "en/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification" ] }, "en/plugins/faq" @@ -383,6 +388,7 @@ "en/learn-more/use-cases/integrate-deepseek-to-build-an-ai-app", "en/learn-more/use-cases/private-ai-ollama-deepseek-dify", "en/learn-more/use-cases/build-an-notion-ai-assistant", + "en/learn-more/use-cases/building-an-ai-thesis-slack-bot", "en/learn-more/use-cases/create-a-midjourney-prompt-bot-with-dify", "en/learn-more/use-cases/create-an-ai-chatbot-with-business-data-in-minutes", "en/learn-more/use-cases/how-to-integrate-dify-chatbot-to-your-wix-website", @@ -467,7 +473,8 @@ "zh-hans/getting-started/install-self-hosted/faq" ] }, - "zh-hans/getting-started/dify-premium" + "zh-hans/getting-started/dify-premium", + "zh-hans/getting-started/dify-for-education" ] }, { @@ -800,13 +807,15 @@ { "group": "最佳实践", "pages": [ - "zh-hans/plugins/best-practice/develop-a-slack-bot-plugin" + "zh-hans/plugins/best-practice/develop-a-slack-bot-plugin", + "zh-hans/plugins/best-practice/how-to-use-mcp-zapier" ] }, { "group": "发布插件", "pages": [ "zh-hans/plugins/publish-plugins/README", + "zh-hans/plugins/publish-plugins/plugin-auto-publish-pr", { "group": "发布至 Dify Marketplace", "pages": [ @@ -816,7 +825,8 @@ ] }, "zh-hans/plugins/publish-plugins/publish-plugin-on-personal-github-repo", - "zh-hans/plugins/publish-plugins/package-plugin-file-and-publish" + "zh-hans/plugins/publish-plugins/package-plugin-file-and-publish", + "zh-hans/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification" ] }, "zh-hans/plugins/faq" @@ -865,6 +875,8 @@ "zh-hans/learn-more/use-cases/train-a-qa-chatbot-that-belongs-to-you", "zh-hans/learn-more/use-cases/create-a-midjoureny-prompt-word-robot-with-zero-code", "zh-hans/learn-more/use-cases/build-an-notion-ai-assistant", + "zh-hans/learn-more/use-cases/building-an-ai-thesis-slack-bot", + "zh-hans/learn-more/use-cases/connect-dify-to-various-im-platforms-by-using-langbot", "zh-hans/learn-more/use-cases/create-an-ai-chatbot-with-business-data-in-minutes", "zh-hans/learn-more/use-cases/practical-implementation-of-building-llm-applications-using-a-full-set-of-open-source-tools", "zh-hans/learn-more/use-cases/dify-on-wechat", @@ -955,7 +967,8 @@ "ja-jp/getting-started/install-self-hosted/faq" ] }, - "ja-jp/getting-started/dify-premium" + "ja-jp/getting-started/dify-premium", + "ja-jp/getting-started/dify-for-education" ] }, { @@ -1072,7 +1085,7 @@ { "group": "ナレッジベースの管理", "pages": [ - "ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/introduction", + "ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/readme", "ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents", "ja-jp/guides/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api" ] @@ -1080,6 +1093,7 @@ "ja-jp/guides/knowledge-base/metadata", "ja-jp/guides/knowledge-base/integrate-knowledge-within-application", "ja-jp/guides/knowledge-base/retrieval-test-and-citation", + "ja-jp/guides/knowledge-base/knowledge-request-rate-limit", "ja-jp/guides/knowledge-base/connect-external-knowledge-base", "ja-jp/guides/knowledge-base/api-documentation/external-knowledge-api-documentation" ] @@ -1255,13 +1269,15 @@ "group": "ベストプラクティス", "pages": [ "ja-jp/plugins/best-practice/README", - "ja-jp/plugins/best-practice/develop-a-slack-bot-plugin" + "ja-jp/plugins/best-practice/develop-a-slack-bot-plugin", + "ja-jp/plugins/best-practice/how-to-use-mcp-zapier" ] }, { "group": "プラグインの公開", "pages": [ "ja-jp/plugins/publish-plugins/README", + "ja-jp/plugins/publish-plugins/plugin-auto-publish-pr", { "group": "Difyマーケットプレイスへの公開", "pages": [ @@ -1271,7 +1287,8 @@ ] }, "ja-jp/plugins/publish-plugins/publish-plugin-on-personal-github-repo", - "ja-jp/plugins/publish-plugins/package-plugin-file-and-publish" + "ja-jp/plugins/publish-plugins/package-plugin-file-and-publish", + "ja-jp/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification" ] }, "ja-jp/plugins/faq" @@ -1319,6 +1336,7 @@ "ja-jp/learn-more/use-cases/private-ai-ollama-deepseek-dify", "ja-jp/learn-more/use-cases/create-a-midjoureny-prompt-word-robot-with-zero-code", "ja-jp/learn-more/use-cases/build-an-notion-ai-assistant", + "ja-jp/learn-more/use-cases/building-an-ai-thesis-slack-bot", "ja-jp/learn-more/use-cases/create-an-ai-chatbot-with-business-data-in-minutes", "ja-jp/learn-more/use-cases/how-to-integrate-dify-chatbot-to-your-wix-website", "ja-jp/learn-more/use-cases/how-to-connect-aws-bedrock", @@ -1377,6 +1395,18 @@ ] }, "redirects": [ + { + "source": "ja-jp/plugins/plugin-auto-publish-pr", + "destination": "ja-jp/plugins/publish-plugins/plugin-auto-publish-pr.mdx" + }, + { + "source": "zh-hans/plugins/plugin-auto-publish-pr", + "destination": "zh-hans/plugins/publish-plugins/plugin-auto-publish-pr.mdx" + }, + { + "source": "en/plugins/plugin-auto-publish-pr", + "destination": "en/plugins/publish-plugins/plugin-auto-publish-pr.mdx" + }, { "source": "zh-hans/getting-started/install-self-hosted", "destination": "zh-hans/getting-started/install-self-hosted/readme" diff --git a/en/community/contribution.mdx b/en/community/contribution.mdx index 1f93b839..db2a5d67 100644 --- a/en/community/contribution.mdx +++ b/en/community/contribution.mdx @@ -75,7 +75,7 @@ Dify requires the following dependencies to build, make sure they're installed o - [Docker Compose](https://docs.docker.com/compose/install/) - [Node.js v18.x (LTS)](http://nodejs.org) - [npm](https://www.npmjs.com/) version 8.x.x or [Yarn](https://yarnpkg.com/) -- [Python](https://www.python.org/) version 3.10.x +- [Python](https://www.python.org/) version 3.11.x #### 4. Installations diff --git a/en/development/models-integration/gpustack.mdx b/en/development/models-integration/gpustack.mdx index c6f1b973..0ad2577c 100644 --- a/en/development/models-integration/gpustack.mdx +++ b/en/development/models-integration/gpustack.mdx @@ -1,11 +1,10 @@ --- -title: Integrating with GPUStack for Local Model Deployment +title: Integrate Local Models Deployed by GPUStack --- +[GPUStack](https://github.com/gpustack/gpustack) is an open-source GPU cluster manager for running AI models. -[GPUStack](https://github.com/gpustack/gpustack) is an open-source GPU cluster manager for running large language models(LLMs). - -Dify allows integration with GPUStack for local deployment of large language model inference, embedding and reranking capabilities. +Dify allows integration with GPUStack for local deployment of large language model inference, embedding, reranking, speech to text and text to speech to capabilities. ## Deploying GPUStack @@ -39,7 +38,7 @@ Using a LLM hosted on GPUStack as an example: 3. Click `Save` to deploy the model. -![gpustack-deploy-llm](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/development/models-integration/35f535a6bb3023aa69a3fdafbdb0c8f3.png) +![gpustack-deploy-llm](https://assets-docs.dify.ai/2025/04/d19b69596b95ae94071f9430a1b983e6.png) ## Create an API Key @@ -63,6 +62,6 @@ Using a LLM hosted on GPUStack as an example: Click "Save" to use the model in the application. -![add-gpustack-llm](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/development/models-integration/8e8851fec5a1515a2284aad68b90ad40.png) +![add-gpustack-llm](https://assets-docs.dify.ai/2025/04/8178418f93ccea1668564d8bd9777303.png) For more information about GPUStack, please refer to [Github Repo](https://github.com/gpustack/gpustack). diff --git a/en/getting-started/cloud.mdx b/en/getting-started/cloud.mdx index 98038d96..d56eaca2 100644 --- a/en/getting-started/cloud.mdx +++ b/en/getting-started/cloud.mdx @@ -30,4 +30,4 @@ A: In Dify Cloud, we anonymize application data to ensure privacy and reduce enc **Q: What is the process for deleting my account and all associated data from Dify Cloud?** -A: If you decide to delete your account and remove all associated data from Dify Cloud, you can simply send a request to our support team at support@dify.ai. We are committed to respecting your privacy and data rights, and upon request, we will erase all your data from our systems, adhering to data protection regulations. +A: If you decide to delete your account and remove all associated data from Dify Cloud, you can visit [Account](https://cloud.dify.ai/account) or click on the avatar in the upper right corner, then click "Account". You will see a "Delete account" button; please click it and follow the instructions. We are committed to respecting your privacy and data rights, and upon request, we will erase all your data from our systems, adhering to data protection regulations. diff --git a/en/getting-started/dify-for-education.mdx b/en/getting-started/dify-for-education.mdx new file mode 100644 index 00000000..b80dbb68 --- /dev/null +++ b/en/getting-started/dify-for-education.mdx @@ -0,0 +1,167 @@ +--- +title: Dify for Education +--- + +## Overview + +**Dify for Education** offers discounted access to Dify for students, teachers, and educational institutions. + +## Value + +- **For Students**: Get discounted access for coursework or AI projects. + +- **For Teachers**: Use Dify as a teaching tool for AI application development + +- **For Educational Institutions & Schools**: Manage AI resources and enhance education. + +## Benefits + +Dify for Education offers **a 50% off coupon for the Dify Professional subscription plan**. + + +More exclusive educational benefits will be added in the future. + + +## How to Apply for Dify for Education + +### Prerequisites + +To qualify for Dify for Education, you must meet **all** of the following requirements: + +1. Be 18 or older. +2. Be a current student, teacher, or educational staff member. +3. Have a valid educational email address. + +### Steps + +1. **Create a Dify Account** + +Before applying for educational verification, [register a Dify account](https://cloud.dify.ai/signin) with your educational email. + +2. **Apply for Educational Verification** + + 1. From your profile menu (top-right), select **Settings**. + + 2. On the Settings page, click **Billing > Get Education Verified**. + + ![Get Education Verified](https://assets-docs.dify.ai/2025/03/662ee0255a499ab4184fd617e0f5767d.png) + + 3. Enter your school’s full name *(no abbreviations)*. + + 4. Select your role. + + 5. Accept the *Terms & Agreements* and click **Submit**. + + ![Get Education Verified Form](https://assets-docs.dify.ai/2025/03/47bf2c0674b04ad7eced99adb57ef7dc.png) + + 6. Once verified, you will receive a Dify Education Coupon. + +## How to Check Dify Educational Verification Status + +Click profile picture (top-right) and look for `Edu` in subscription status. + +## How to Use Dify Education Coupon + +### Dify Education Coupon + +Your account will receive a Dify Education coupon after verification. Use this coupon to get discounts on the Dify Professional subscription plan. + + +Discount: **50%** + +Validity: **12 months** + +Limitations: +- Coupons must be used within the validity period; **expired coupons are invalid**. +- Educational verification can only be applied for **once** per year, and only **one coupon** can be obtained per application. +- Coupons can only be applied to workspaces where you are the Workspace Owner. + + +### Use Education Coupon + +1. On the pricing page, select the Dify Professional plan. + +- Monthly payment: Click **Get Started** to go to the payment page. +- Annual payment: Toggle **Annual Billing** and click **Get Started** to go to the payment page. + +2. On the payment page, your promo code applies automatically. Check the discount and discounted price. + +![Promo Code](https://assets-docs.dify.ai/2025/03/b72d21a1df9cfa1adcf2271fa8d9bb69.png) + +3. After confirming order details, select a payment method. + +4. Complete the payment to finalize subscription. + +5. Once subscribed, your subscription status will be updated to `Pro(Edu)`. + +## How to Update My Educational Information + +### Update Email + +Email `` to change your email address. + +### Update School Information + +- **For verified accounts**: Email `` to modify school details. + +- **For expired verification**: Enter new school information during re-verification. + +## How to Renew Dify Educational Verification + +Follow the steps in **Apply for Educational Verification** to renew verification. + +## FAQ + +- **How can I learn about Dify?** + +1. Read the [Dify official documentation](https://docs.dify.ai/) for guides. + +2. Join the [Dify Discord community](https://discord.com/invite/FngNHpbcY7) to share your experiences with developers. + +- **How much do Dify plans cost?** + +See [pricing page](https://dify.ai/pricing) for more information. + +- **Who cannot apply for educational verification?** + +1. Users under 18 years old. + +2. Users registered with personal emails (e.g., Gmail). + +- **Why was my educational verification rejected/revoked? What should I do if my application is rejected/revoked?** + +Your educational verification application may be rejected or revoked in the following situations: + +1. Did not accept ***Terms & Agreements*** when applying for educational verification +2. Non-educational email registration +3. Fraudulent email or information +4. Educational privilege misuse +5. False institutional information + +To appeal a rejected/revoked verification, please email `` for assistance. + +- **Will my educational verification remain valid after I graduate or leave school?** + +Your verification remains valid while your educational email is active. Email `` for assistance if your educational email expires. + +- **I don’t have an educational email. How can I apply for educational verification?** + +Educational verification requires a valid institutional email address. Personal emails are not eligible. + +- **I had a subscription that expired. Can I still use the promo code?** + +Yes. If your Stripe payment info are saved, the promo code will automatically apply when you resubscribe. + +- **What happens to my plan after educational verification is approved?** + +For Professional Plan users, the promo code applies at your next billing period. For other plans’ users, the promo code is saved and applies when you change it to Professional. + +- **What happens if I cancel my professional subscription plan after educational verification but before my next billing date?** + +Your plan continues until the billing period ends, but the promo code expires permanently. + +- **I canceled my subscription and then apply for Dify for Education. Can I still use the promo code?** + +Yes, but timing matters: +1. Your current subscription must expire before resubscribing for the promo code to apply. +2. The promo code will not apply if you renew or change plans before your subscription expires. diff --git a/en/getting-started/dify-premium.mdx b/en/getting-started/dify-premium.mdx index 36bb3346..3eeac16e 100644 --- a/en/getting-started/dify-premium.mdx +++ b/en/getting-started/dify-premium.mdx @@ -109,3 +109,7 @@ Just like self-hosted deploy, you may modify the environment variables under `.e docker-compose down docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d ``` + +## WebApp Logo & Branding Customization + +You can enable this feature in **Customization** under settings, enable **Remove Powered by Dify** and upload your own logo. diff --git a/en/getting-started/install-self-hosted/environments.mdx b/en/getting-started/install-self-hosted/environments.mdx index 22821a2d..4725abe4 100644 --- a/en/getting-started/install-self-hosted/environments.mdx +++ b/en/getting-started/install-self-hosted/environments.mdx @@ -1,7 +1,14 @@ --- -title: Environments +title: Environments(待处理) --- + +This document may be outdated. Please refer to the latest configuration files: + +- [docker-compose.yaml](https://github.com/langgenius/dify/blob/5f8d20b5b2bb51f19547467167b18d9c0f6ffbb8/docker/docker-compose.yaml) + +- [.env.example](https://github.com/langgenius/dify/blob/5f8d20b5b2bb51f19547467167b18d9c0f6ffbb8/docker/.env.example) + ### Common Variables diff --git a/en/getting-started/install-self-hosted/faqs.mdx b/en/getting-started/install-self-hosted/faqs.mdx index 43dbe48b..5ac717d8 100644 --- a/en/getting-started/install-self-hosted/faqs.mdx +++ b/en/getting-started/install-self-hosted/faqs.mdx @@ -2,7 +2,6 @@ title: FAQs --- - ### 1. Not receiving reset password emails You need to configure the `Mail` parameters in the `.env` file. For detailed instructions, please refer to ["Environment Variables Explanation: Mail-related configuration"](/en/getting-started/install-self-hosted/environments#mail-related-configuration). @@ -67,5 +66,24 @@ EXPOSE_NGINX_PORT=80 EXPOSE_NGINX_SSL_PORT=443 ``` +Other self-host issue please check this document [Self-Host Related](/en/learn-more/faq/install-faq)。 + +### 6. How to resolve database connection errors in docker-api-1? + +**Issue Details**: When accessing `http://localhost`, you may encounter an `Internal Server Error`; and the following message might appear in the `docker-api-1` logs: + +```bash +FATAL: no pg_hba.conf entry for host "172.19.0.7", user "postgres", database "dify", no encryption +``` + +**Solution**: Update the `/var/lib/postgresql/pgdata/pg_hba.conf` file inside the db container to allow connections from the network segment mentioned in the error message. For example: + +```bash +docker exec -it docker-db-1 sh -c "echo 'host all all 172.19.0.0/16 trust' >> /var/lib/postgresql/data/pgdata/pg_hba.conf" +docker-compose restart +``` + +### 7. How to change the file size limit for knowledge base uploads? + +Modify the `UPLOAD_FILE_SIZE_LIMIT` parameter in the `.env` file to adjust the default limit. Additionally, you should also sync the `NGINX_CLIENT_MAX_BODY_SIZE` parameter value to avoid potential issues. -Other self-host issue please check this document [Self-Host Related](/en/learn-more/faq/install-faq)。 \ No newline at end of file diff --git a/en/getting-started/install-self-hosted/local-source-code.mdx b/en/getting-started/install-self-hosted/local-source-code.mdx index 218346b0..ee0471b0 100644 --- a/en/getting-started/install-self-hosted/local-source-code.mdx +++ b/en/getting-started/install-self-hosted/local-source-code.mdx @@ -221,7 +221,8 @@ Please visit [https://nodejs.org/en/download](https://nodejs.org/en/download) an 2. Install the dependencies. ``` - npm install + npm i -g pnpm + pnpm install ``` 3. Configure the environment variables. Create a file named .env.local in the current directory and copy the contents from .env.example. Modify the values of these environment variables according to your requirements: diff --git a/en/getting-started/readme/model-providers.mdx b/en/getting-started/readme/model-providers.mdx index e2d29804..d5a1751d 100644 --- a/en/getting-started/readme/model-providers.mdx +++ b/en/getting-started/readme/model-providers.mdx @@ -384,6 +384,14 @@ Dify supports the below model providers out-of-box: + + GPUStack + ✔️(🔧️)(👓) + ✔️ + ✔️ + ✔️ + ✔️ + diff --git a/en/guides/application-orchestrate/creating-an-application.mdx b/en/guides/application-orchestrate/creating-an-application.mdx index 6c0e14e7..be1b7dbe 100644 --- a/en/guides/application-orchestrate/creating-an-application.mdx +++ b/en/guides/application-orchestrate/creating-an-application.mdx @@ -26,7 +26,7 @@ If you need to create a blank application on Dify, you can select "Studio" from ![Create a blank application](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/application-orchestrate/f3fac01ad131b23ff8f45fa81a40d8a6.png) -When creating an application for the first time, you might need to first understand the [basic concepts](./#application_type) of the four different types of applications on Dify: Chatbot, Text Generator, Agent, Chatflow and Workflow. +When creating an application for the first time, you might need to first understand the [basic concepts](./#application_type) of the five different types of applications on Dify: Chatbot, Text Generator, Agent, Chatflow and Workflow. When selecting a specific application type, you can customize it by providing a name, choosing an appropriate icon(or uploading your favorite image as an icon), and writing a clear and concise description of its purpose. These details will help team members easily understand and use the application in the future. diff --git a/en/guides/application-publishing/launch-your-webapp-quickly/README.mdx b/en/guides/application-publishing/launch-your-webapp-quickly/README.mdx index d0c55f0f..4d60fc05 100644 --- a/en/guides/application-publishing/launch-your-webapp-quickly/README.mdx +++ b/en/guides/application-publishing/launch-your-webapp-quickly/README.mdx @@ -42,4 +42,4 @@ Currently, Web App supports multiple languages: English, Simplified Chinese, Tra ### Embedding Your AI Site -You can also integrate Dify Web App into your own web project, blog, or any other web page. For more details, please take a refer to [Embedding In Websites](/en/guides/application-publishing/embedding-in-websites). +You can also integrate Dify Web App into your own web project, blog, or any other web page. For more details, please refer to [Embedding In Websites](/en/guides/application-publishing/embedding-in-websites). diff --git a/en/guides/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx b/en/guides/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx index f555e5f9..431b18ae 100644 --- a/en/guides/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx +++ b/en/guides/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx @@ -10,7 +10,7 @@ POST /retrieval ## Header -This API is used to connect to a knowledge base that is independent of the Dify and maintained by developers. For more details, please refer to [Connecting to an External Knowledge Base](/en/guides/knowledge-base/connect-external-knowledge-base). You can use `API-Key` in the `Authorization` HTTP Header to verify permissions. The authentication logic is defined by you in the retrieval API, as shown below: +This API is used to connect to a knowledge base that is independent of the Dify and maintained by developers. For more details, please refer to [Connecting to an External Knowledge Base](https://docs.dify.ai/guides/knowledge-base/connect-external-knowledge-base). You can use `API-Key` in the `Authorization` HTTP Header to verify permissions. The authentication logic is defined by you in the retrieval API, as shown below: ``` Authorization: Bearer {API_KEY} @@ -25,6 +25,7 @@ The request accepts the following data in JSON format. | knowledge_id | TRUE | string | Your knowledge's unique ID | AAA-BBB-CCC | | query | TRUE | string | User's query | What is Dify? | | retrieval_setting | TRUE | object | Knowledge's retrieval parameters | See below | +| metadata_condition | FALSE | Object | Original array filtering | See below | The `retrieval_setting` property is an object containing the following keys: @@ -33,6 +34,40 @@ The `retrieval_setting` property is an object containing the following keys: | top_k | TRUE | int | Maximum number of retrieved results | 5 | | score_threshold | TRUE | float | The score limit of relevance of the result to the query, scope: 0~1 | 0.5 | +The `metadata_condition` property is an object containing the following keys: + +| Attribute | Required | Type | Description | Example Value | +|-----------|----------|------|-------------|--------------| +| logical_operator | No | String | Logical operator, values can be `and` or `or`, default is `and` | and | +| conditions | Yes | Array (Object) | List of conditions | See below | + +Each object in the `conditions` array contains the following keys: + +| Attribute | Required | Type | Description | Example Value | +|-----------|----------|------|-------------|--------------| +| name | Yes | Array (String) | Names of the metadata to filter | `["category", "tag"]` | +| comparison_operator | Yes | String | Comparison operator | `contains` | +| value | No | String | Comparison value, can be omitted when the operator is `empty`, `not empty`, `null`, or `not null` | `"AI"` | + +Supported `comparison_operator` operators: + +- `contains`: Contains a certain value +- `not contains`: Does not contain a certain value +- `start with`: Starts with a certain value +- `end with`: Ends with a certain value +- `is`: Equals a certain value +- `is not`: Does not equal a certain value +- `empty`: Is empty +- `not empty`: Is not empty +- `=`: Equals +- `≠`: Not equal +- `>`: Greater than +- `<`: Less than +- `≥`: Greater than or equal to +- `≤`: Less than or equal to +- `before`: Before a certain date +- `after`: After a certain date + ## Request Syntax ```json @@ -105,7 +140,7 @@ If the action fails, the service sends back the following error information in J | Property | Required | Type | Description | Example value | |----------|----------|------|-------------|---------------| | error_code | TRUE | int | Error code | 1001 | -| error_msg | TRUE | string | The description of API exception | Invalid Authorization header format. Expected 'Bearer ``' format. | +| error_msg | TRUE | string | The description of API exception | Invalid Authorization header format. Expected 'Bearer ' format. | The `error_code` property has the following types: @@ -124,3 +159,17 @@ HTTP Status Code: 403 **InternalServerException** An internal server error occurred. Retry your request. HTTP Status Code: 500 + +## Development Example + +You can learn how to develop external knowledge base plugins through the following video tutorial using LlamaCloud as an example: + + - * **单文件** 仅允许应用使用者上传单个文件。 diff --git a/zh-hans/guides/workflow/node/agent.mdx b/zh-hans/guides/workflow/node/agent.mdx index 15596219..51fddb01 100644 --- a/zh-hans/guides/workflow/node/agent.mdx +++ b/zh-hans/guides/workflow/node/agent.mdx @@ -71,3 +71,11 @@ ReAct 策略使 Agent 交替进行思考和行动:LLM 首先思考当前状态 Agent 节点执行过程中将生成详细日志。显示节点执行的总体信息,包括输入和输出、token 开销、耗时和状态。点击 "详情" 查看 Agent 策略执行的每一轮输出信息。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/2dff44986829dfd100ee03c8eb89f94a.png) + +## 记忆 + +启用记忆开关可以为 Agent 提供对话上下文记忆能力。通过调整记忆窗口滑块,你可以控制 Agent 能够“记住”的对话历史消息数量。这使 Agent 能够理解和引用先前的交流内容,从而提供连贯且上下文相关的回答,大幅提升多轮对话体验。 + +例如,当用户在后续消息中使用代词(如“它”、“这个”或“他们”)时,启用了记忆功能的 Agent 能够理解这些代词所指代的前文实体,无需用户重复提及完整信息。 + + diff --git a/zh-hans/guides/workflow/node/llm.mdx b/zh-hans/guides/workflow/node/llm.mdx index 1bbd8103..b2d78e57 100644 --- a/zh-hans/guides/workflow/node/llm.mdx +++ b/zh-hans/guides/workflow/node/llm.mdx @@ -62,7 +62,7 @@ LLM 节点是 Chatflow/Workflow 的核心节点。该节点能够利用大语言 呼出变量插入菜单 -5. **高级设置**,可以开关记忆功能并设置记忆窗口、开关 Vision 功能或者使用 Jinja-2 模版语言来进行更复杂的提示词等。 +5. **高级设置**,可以开关记忆功能并设置记忆窗口、开关 Vision 功能或者使用 Jinja-2 模板语言来进行更复杂的提示词等。 *** diff --git a/zh-hans/guides/workflow/node/loop.mdx b/zh-hans/guides/workflow/node/loop.mdx index 1c85808c..a92b86f2 100644 --- a/zh-hans/guides/workflow/node/loop.mdx +++ b/zh-hans/guides/workflow/node/loop.mdx @@ -1,7 +1,9 @@ --- -title: Loop +title: 循环 --- +## 简介 + 循环(Loop)节点用于执行依赖前一轮结果的重复任务,直到满足退出条件或达到最大循环次数。 ## 循环节点与迭代节点有什么区别? @@ -20,70 +22,118 @@ title: Loop 循环(Loop) 轮次之间存在依赖关系的优化型任务。即任务的每一轮执行都依赖上一轮的结果。 - 需要前一轮的计算结果,适用于递归、优化问题等。 + 需要前一轮的计算结果。 迭代(Iteration) 轮次之间无依赖关系的批处理任务。即每一轮任务可以独立运行,无需依赖前一轮。 - 每轮独立执行,可用于数据批量处理等。 + 每轮独立执行。 ## 如何配置循环节点? -循环节点包含以下两个关键配置项: +循环节点包含以下三个关键配置项和一个子节点: - + - - + + - + + + + + + + + + + +
配置项配置项/子节点 作用 示例
循环退出条件(Loop Termination Condition)设置循环何时停止循环终止条件(Loop Termination Condition)设置循环何时停止。 例:当变量 x < 50 时,停止循环。
最大循环次数(Maximum Loop Count)限制最多执行的轮次,避免无限循环限制最多执行的轮次,避免无限循环。例:最多执行 10 轮,不管是否满足退出条件。
循环变量(Loop Variables)用于在循环的不同轮次间传递数据,并在循环结束后继续供下游节点使用。例:变量 x < 50 在每轮循环中递增 1,循环体内部可以基于 x < 50 进行计算,循环结束后,x < 50 的最终值可用于后续流程。
退出循环节点(Exit Loop)当循环体内运行到此节点后,循环终止。 例:最多执行 10 轮,不管是否满足退出条件。
-你可以在 **循环退出条件** 中使用循环体内的变量或会话中的全局变量,让循环按照你的需求停止。 + +**退出循环节点** 与 **循环终止条件** 均可作为循环的终止触发点,满足任意一个条件时,循环都会提前退出。 -![Configuration](https://assets-docs.dify.ai/2025/03/13853bfaaa068cdbdeba1b1f75d482f2.png) +如果未配置任何退出条件,则循环将持续运行(相当于 while (true)),直到达到 **最大循环次数**。 + -## 示例:如何使用循环节点? +## 示例一:如何使用循环节点? **需求:生成 1-100 的随机数,直到随机数小于 50 时停止。** **实现步骤**: -1. 使用 `code` 节点生成 `1-100` 的随机数。 +1. 在 **循环** 节点中,配置 **循环终止条件**,为 **模板转换** 节点输出 `done`。 -2. 使用 `if` 节点判断随机数是否小于 `50`: +2. 使用 **代码执行** 节点生成 `1-100` 的随机数。 - - 如果小于 50,输出 `done` 并结束循环。 +3. 使用 **条件分支** 节点判断随机数是否大于 `50`: - - 如果不小于 50,继续循环,生成新的随机数。 + - 如果大于或等于 50,输出 `当前数字` 并继续循环,生成新的随机数。 -3. 设置循环退出标准:随机数 `< 50`。 + - 如果小于 50,输出 `最终输出数字`,并经由 **模板转换** 节点输出 `done`,结束循环。 4. 循环将在随机数小于 `50` 时自动停止。 -![Case steps](https://assets-docs.dify.ai/2025/03/b1c277001fc3cb1fbb85fe7c22a6d0fc.png) +![Basic loop workflow](https://assets-docs.dify.ai/2025/04/282013c48b46d3cc4ebf99323da10a31.png) -## 未来扩展 +![Steps](https://assets-docs.dify.ai/2025/04/9d9fb4db7093521000ac735a26f86962.png) -**后续版本将提供:** +## 示例二:如何使用循环变量与退出循环节点? -- 循环变量:支持在循环过程中存储和引用变量,增强逻辑控制能力。 +**需求:通过一个循环工作流生成并逐步重写一首诗,每次输出都基于上一轮的结果。循环执行 4 次后自动停止。** -- `break` 节点:允许在循环体内部直接终止循环,适用于更复杂的流程控制。 +**实现步骤:** + +1. 在 **循环** 节点中,配置 **循环变量**,用于在每次迭代中传递数据: + + - num(循环次数):初始值为 0,每次循环 +1。 + + - verse(诗歌内容):初始值 `I haven’t started creating yet`,后续每次循环更新。 + +2. 使用 **条件分支** 节点判断循环次数是否大于 `3`: + + - 如果大于 3,则进入 **退出循环** 节点,结束循环。 + + - 如果小于或等于 3,则进入 **LLM** 节点继续循环。 + +3. 使用 **LLM** 节点,要求模型根据用户的输入和过往的创作输出诗歌内容。 + + +参考 Prompt: + +- 使用用户的输出 `sys.query` 作为灵感,创作一首欧洲长诗。 + +- 参考你上一次的创作 `verse`,尝试在新的诗句中展现进步和创新。 + +- 确保你的诗句符合欧洲文学的风格和传统,注重诗歌的韵律和意境。 + + +在第一次循环时,verse 为 `I haven’t started creating yet`,之后每次循环根据上一轮的输出更新诗歌。每次模型生成的新诗歌都会覆盖 verse 变量,供下一次循环使用。 + +4. 使用 **变量赋值** 节点,在每次循环后更新循环中的变量: + + - 更新 num 变量,每次循环 +1。 + + - 更新 verse 变量为模型新生成的诗歌内容,直接覆盖前一轮循环的诗歌内容。 + +5. 输入你的诗歌灵感,模型将输出四个版本的诗歌,每一篇诗歌都以前一篇为基础而产生。 + + diff --git a/zh-hans/guides/workflow/node/parameter-extractor.mdx b/zh-hans/guides/workflow/node/parameter-extractor.mdx index 4684c4da..8fc95938 100644 --- a/zh-hans/guides/workflow/node/parameter-extractor.mdx +++ b/zh-hans/guides/workflow/node/parameter-extractor.mdx @@ -28,7 +28,7 @@ Dify 工作流内提供了丰富的[工具](https://docs.dify.ai/v/zh-hans/guide *** -### 3 如何配置 +### 如何配置 ![参数提取配置界面](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/2171232dfe8a907ebad05cef8b789c9a.png) diff --git a/zh-hans/guides/workflow/node/template.mdx b/zh-hans/guides/workflow/node/template.mdx index 52d34759..f96df6d7 100644 --- a/zh-hans/guides/workflow/node/template.mdx +++ b/zh-hans/guides/workflow/node/template.mdx @@ -45,4 +45,33 @@ version: '简体中文' 知识检索节点输出转换为 Markdown示例 -你可以参考 Jinja 的[官方文档](https://jinja.palletsprojects.com/en/3.1.x/templates/),创建更为复杂的模板来执行各种任务。 \ No newline at end of file +你可以参考 Jinja 的[官方文档](https://jinja.palletsprojects.com/en/3.1.x/templates/),创建更为复杂的模板来执行各种任务。 + +**示例 3:** 支持渲染 HTML 的表单 +```html +
// Default to text + + + + + + + + + + + + + + + + +
+``` + + diff --git a/zh-hans/guides/workflow/nodes/README.mdx b/zh-hans/guides/workflow/nodes/README.mdx deleted file mode 100644 index 836abd41..00000000 --- a/zh-hans/guides/workflow/nodes/README.mdx +++ /dev/null @@ -1,7 +0,0 @@ -# 节点说明 - -**节点是工作流中的关键构成**,通过连接不同功能的节点,执行工作流的一系列操作。 - -### 核心节点 - -
开始(Start)定义一个 workflow 流程启动的初始参数。
结束(End)定义一个 workflow 流程结束的最终输出内容。
回复(Answer)定义一个 Chatflow 流程中的回复内容。
大语言模型(LLM)调用大语言模型回答问题或者对自然语言进行处理。
知识检索(Knowledge Retrieval)从知识库中检索与用户问题相关的文本内容,可作为下游 LLM 节点的上下文。
问题分类(Question Classifier)通过定义分类描述,LLM 能够根据用户输入选择与之相匹配的分类。
条件分支(IF/ELSE)允许你根据 if/else 条件将 workflow 拆分成两个分支。
代码执行(Code)运行 Python / NodeJS 代码以在工作流程中执行数据转换等自定义逻辑。
模板转换(Template)允许借助 Jinja2 的 Python 模板语言灵活地进行数据转换、文本处理等。
变量聚合(Variable Aggregator)将多路分支的变量聚合为一个变量,以实现下游节点统一配置。
参数提取器(Parameter Extractor)利用 LLM 从自然语言推理并提取结构化参数,用于后置的工具调用或 HTTP 请求。
迭代(Iteration)对列表对象执行多次步骤直至输出所有结果。
HTTP 请求(HTTP Request)允许通过 HTTP 协议发送服务器请求,适用于获取外部检索结果、webhook、生成图片等情景。
工具(Tools)允许在工作流内调用 Dify 内置工具、自定义工具、子工作流等。
变量赋值(Variable Assigner)变量赋值节点用于向可写入变量(例如会话变量)进行变量赋值。
diff --git a/zh-hans/guides/workflow/nodes/agent.mdx b/zh-hans/guides/workflow/nodes/agent.mdx deleted file mode 100644 index 15596219..00000000 --- a/zh-hans/guides/workflow/nodes/agent.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: Agent ---- - -## 定义 - -Agent 节点是 Dify Chatflow/Workflow 中用于实现自主工具调用的组件。它通过集成不同的 Agent 推理策略,使大语言模型能够在运行时动态选择并执行工具,从而实现多步推理。 - -## 配置步骤 - -### 添加节点 - -在 Dify Chatflow/Workflow 编辑器中,从组件栏拖拽 Agent 节点至画布。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/17317ea064e250fc603c32232f0e93d2.png) - -### 选择 Agent 策略 - -在节点配置面板中,点击 **Agent 策略**。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/2a6897e97b7ad534afdbe74bd7272426.png) - -从下拉菜单选择所需的 Agent 推理策略。Dify 内置了 **Function Calling 和 ReAct** 两种策略,可在 **Marketplace** → **Agent 策略**分类中安装使用。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/41a147e0bfa027b801c09668adec7d19.png) - -#### 1. Function Calling - -通过将用户指令映射到预定义函数或工具,LLM 先识别用户意图,再决定调用哪个函数并提取所需参数。它的核心是调用外部函数或工具,属于一种明确的工具调用机制。 - -**优点:** - -* **精确:** 对于明确的任务,可以直接调用相应的工具,无需复杂的推理过程。 -* **易于集成外部功能:** 可以将各种外部 API 或工具封装成函数供模型调用。 -* **结构化输出:** 模型输出的是结构化的函数调用信息,方便下游节点处理。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/312b854ad40f88a079f4ddaf7f99d0ee.png) - -2. **ReAct (Reason + Act)** - -ReAct 策略使 Agent 交替进行思考和行动:LLM 首先思考当前状态和目标,然后选择并调用合适的工具,工具的输出结果又将引导 LLM 进行下一步的思考和行动,如此循环,直到问题解决。 - -**优点:** - -* **有效利用外部信息:** 能够有效地利用外部工具获取信息,解决仅靠模型自身无法完成的任务。 -* **可解释性较好:** 思考和行动的过程是交织的,可以一定程度上追踪 Agent 的推理路径。 -* **适用范围广:** 适用于需要外部知识或需要执行特定操作的场景,例如问答、信息检索、任务执行等。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/9196af3b81d8b02a8dcd21ac917825a6.png) - -开发者可以向[公开仓库](https://github.com/langgenius/dify-plugins)贡献 Agent 策略插件,经过审核后将在 Marketplace 上架,供其他用户安装使用。 - -### **配置节点参数** - -选择 Agent 策略后,配置面板会显示对应的配置项。Dify 官方内置的 Function Calling 和 ReAct 策略的配置项包括: - -1. **模型:** 选择驱动 Agent 的大语言模型。 -2. **工具:** 工具的使用方式由 Agent 策略定义,点击 "+" 添加并配置 Agent 可调用的工具。 - * **搜索:** 在下拉框中选择已安装的工具插件。 - * **授权:** 填写 API 密钥等授权信息后启用工具。 - * **工具描述和参数设置:** 提供工具描述,帮助 LLM 理解工具用途并选择调用,同时设置工具的功能参数。 -3. **指令:** 定义 Agent 的任务目标和上下文。支持使用 Jinja 语法引用上游节点变量。 -4. **查询:** 接收用户输入。 -5. **最大迭代次数:** 设定 Agent 的最大执行步数。 -6. **输出变量:** 提示节点输出的数据结构。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/d028e9dc111eca4fe4f7f0b25e75c4b0.png) - -## **查看日志** - -Agent 节点执行过程中将生成详细日志。显示节点执行的总体信息,包括输入和输出、token 开销、耗时和状态。点击 "详情" 查看 Agent 策略执行的每一轮输出信息。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/2dff44986829dfd100ee03c8eb89f94a.png) diff --git a/zh-hans/guides/workflow/nodes/answer.mdx b/zh-hans/guides/workflow/nodes/answer.mdx deleted file mode 100644 index fe80c088..00000000 --- a/zh-hans/guides/workflow/nodes/answer.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: 直接回复 -version: '简体中文' ---- - -### 定义 - -定义一个 Chatflow 流程中的回复内容。 - -你可以在文本编辑器中自由定义回复格式,包括自定义一段固定的文本内容、使用前置步骤中的输出变量作为回复内容、或者将自定义文本与变量组合后回复。 - -可随时加入节点将内容流式输出至对话回复,支持所见即所得配置模式并支持图文混排,如: - -1. 输出 LLM 节点回复内容 -2. 输出生成图片 -3. 输出纯文本 - - -直接回复节点可以不作为最终的输出节点,作为流程过程节点时,可以在中间步骤流式输出结果。 - - diff --git a/zh-hans/guides/workflow/nodes/code.mdx b/zh-hans/guides/workflow/nodes/code.mdx deleted file mode 100644 index 8e30b651..00000000 --- a/zh-hans/guides/workflow/nodes/code.mdx +++ /dev/null @@ -1,122 +0,0 @@ ---- -title: 代码执行 ---- - -## 目录 - -* [介绍](#介绍) -* [使用场景](#使用场景) -* [本地部署](#本地部署) -* [安全策略](#安全策略) - -## 介绍 - -代码节点支持运行 Python / NodeJS 代码以在工作流程中执行数据转换。它可以简化你的工作流程,适用于Arithmetic、JSON transform、文本处理等情景。 - -该节点极大地增强了开发人员的灵活性,使他们能够在工作流程中嵌入自定义的 Python 或 Javascript 脚本,并以预设节点无法达到的方式操作变量。通过配置选项,你可以指明所需的输入和输出变量,并撰写相应的执行代码: - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/9969aa1bc1912aebe366f5d8f5dde296.png) - -## 配置 - -如果你需要在代码节点中使用其他节点的变量,你需要在`输入变量`中定义变量名,并引用这些变量,可以参考[变量引用](../concepts#变量)。 - -## 使用场景 - -使用代码节点,你可以完成以下常见的操作: - -### 结构化数据处理 - -在工作流中,经常要面对非结构化的数据处理,如JSON字符串的解析、提取、转换等。最典型的例子就是HTTP节点的数据处理,在常见的API返回结构中,数据可能会被嵌套在多层JSON对象中,而我们需要提取其中的某些字段。代码节点可以帮助你完成这些操作,下面是一个简单的例子,它从HTTP节点返回的JSON字符串中提取了`data.name`字段: - -```python -def main(http_response: str) -> str: - import json - data = json.loads(http_response) - return { - # 注意在输出变量中声明result - 'result': data['data']['name'] - } -``` - -### 数学计算 - -当工作流中需要进行一些复杂的数学计算时,也可以使用代码节点。例如,计算一个复杂的数学公式,或者对数据进行一些统计分析。下面是一个简单的例子,它计算了一个数组的平方差: - -```python -def main(x: list) -> float: - return { - # 注意在输出变量中声明result - 'result' : sum([(i - sum(x) / len(x)) ** 2 for i in x]) / len(x) - } -``` - -### 拼接数据 - -有时,也许你需要拼接多个数据源,如多个知识检索、数据搜索、API调用等,代码节点可以帮助你将这些数据源整合在一起。下面是一个简单的例子,它将两个知识库的数据合并在一起: - -```python -def main(knowledge1: list, knowledge2: list) -> list: - return { - # 注意在输出变量中声明result - 'result': knowledge1 + knowledge2 - } -``` - -## 本地部署 - -如果你是本地部署的用户,你需要启动一个沙盒服务,它会确保恶意代码不会被执行,同时,启动该服务需要使用Docker服务,你可以在[这里](https://github.com/langgenius/dify/tree/main/docker/docker-compose.middleware.yaml)找到Sandbox服务的具体信息,你也可以直接通过`docker-compose`启动服务: - -```bash -docker-compose -f docker-compose.middleware.yaml up -d -``` - -> 如果你的系统安装了 Docker Compose V2 而不是 V1,请使用 `docker compose` 而不是 `docker-compose`。通过`$ docker compose version`检查这是否为情况。在[这里](https://docs.docker.com/compose/#compose-v2-and-the-new-docker-compose-command)阅读更多信息。 - -## 安全策略 - -无论是 Python3 还是 Javascript 代码执行器,它们的执行环境都被严格隔离(沙箱化),以确保安全性。这意味着开发者不能使用那些消耗大量系统资源或可能引发安全问题的功能,例如直接访问文件系统、进行网络请求或执行操作系统级别的命令。这些限制保证了代码的安全执行,同时避免了对系统资源的过度消耗。 - -### 高级功能 - -**错误重试** - -针对节点发生的部分异常情况,通常情况下再次重试运行节点即可解决。开启错误重试功能后,节点将在发生错误的时候按照预设策略进行自动重试。你可以调整最大重试次数和每次重试间隔以设置重试策略。 - -- 最大重试次数为 10 次 -- 最大重试间隔时间为 5000 ms - -![](https://assets-docs.dify.ai/2024/12/9fdd5525a91dc925b79b89272893becf.png) - -**异常处理** - -代码节点处理信息时有可能会遇到代码执行异常的情况。应用开发者可以参考以下步骤配置异常分支,在节点出现异常时启用应对方案,而避免中断整个流程。 - -1. 在代码节点启用 “异常处理” -2. 选择异常处理方案并进行配置 - -![Code Error handling](https://assets-docs.dify.ai/2024/12/58f392734ce44b22cd8c160faf28cd14.png) - -需了解更多应对异常的处理办法,请参考[异常处理](../error-handling/readme)。 - -### 常见问题 - -**在代码节点内填写代码后为什么无法保存?** - -请检查代码是否包含危险行为。例如: - -```python -def main() -> dict: - return { - "result": open("/etc/passwd").read(), - } -``` - -这段代码包含以下问题: - -* **未经授权的文件访问:** 代码试图读取 "/etc/passwd" 文件,这是 Unix/Linux 系统中存储用户账户信息的关键系统文件。 -* **敏感信息泄露:** "/etc/passwd" 文件包含系统用户的重要信息,如用户名、用户 ID、组 ID、home 目录路径等。直接访问可能会导致信息泄露。 - -危险代码将会被 Cloudflare WAF 自动拦截,你可以通过 “网页调试工具” 中的 “网络” 查看是否被拦截。 - -![Cloudflare WAF](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/d1fe121991c51b26b66d42a55b18fb57.png) diff --git a/zh-hans/guides/workflow/nodes/doc-extractor.mdx b/zh-hans/guides/workflow/nodes/doc-extractor.mdx deleted file mode 100644 index 62072db9..00000000 --- a/zh-hans/guides/workflow/nodes/doc-extractor.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: 文档提取器 -version: '简体中文' ---- - -### 定义 - -LLM 自身无法直接读取或解释文档的内容。因此需要将用户上传的文档,通过文档提取器节点解析并读取文档文件中的信息,转化文本之后再将内容传给 LLM 以实现对于文件内容的处理。 - -### 应用场景 - -* 构建能够与文件进行互动的 LLM 应用,例如 ChatPDF 或 ChatWord; -* 分析并检查用户上传的文件内容; - -### 节点功能 - -文档提取器节点可以理解为一个信息处理中心,通过识别并读取输入变量中的文件,提取信息后并转化为 string 类型输出变量,供下游节点调用。 - -![文档提取器节点](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/c5d46ad8a0d315dbd097824d3d9cc88a.png) - -文档提取器节点结构分为输入变量、输出变量。 - -#### 输入变量 - -文档提取器仅接受以下数据结构的变量: - -* `File`,单独一个文件 -* `Array[File]`,多个文件 - -文档提取器仅能够提取文档类型文件中的信息,例如 TXT、Markdown、PDF、HTML、DOCX 格式文件的内容,无法处理图片、音频、视频等格式文件。 - -#### 输出变量 - -输出变量固定命名为 text。输出的变量类型取决于输入变量: - -* 输入变量为 `File`,输出变量为 `string` -* 输入变量为 `Array[File]`,输出变量为 `array[string]` - -> Array 数组变量一般需配合列表操作节点使用,详细说明请参考 [list-operator.md](list-operator "mention")。 - -### 配置示例 - -在一个典型的文件交互问答场景中,文档提取器可以作为 LLM 节点的前置步骤,提取应用的文件信息并传递至下游的 LLM 节点,回答用户关于文件的问题。 - -本章节将通过一个典型的 ChatPDF 示例工作流模板,介绍文档提取器节点的使用方法。 - -![ChatPDF 工作流](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/65f6abbf733b9e3f51c5425637dbec9a.png) - -**配置流程:** - -1. 为应用开启文件上传功能。在 ["开始"](start) 节点中添加**单文件变量**并命名为 `pdf`。 -2. 添加文档提取节点,并在输入变量内选中 `pdf` 变量。 -3. 添加 LLM 节点,在系统提示词内选中文档提取器节点的输出变量。LLM 可以通过该输出变量读取文件中的内容。 - -![填写文档提取器的输出变量](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/d17113e0b6601d18686cdfde7ca2f666.png) - -4\. 配置结束节点,在结束节点中选择 LLM 节点的输出变量。 - -配置完成后,应用将具备文件上传功能,使用者可以上传 PDF 文件并展开对话。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/92211d8c7cdf4e00393e97c158ebe5ad.png) - - -如需了解如何在聊天对话中上传文件并与 LLM 互动,请参考 [附加功能](/zh-hans/guides/workflow/additional-feature)。 - \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/end.mdx b/zh-hans/guides/workflow/nodes/end.mdx deleted file mode 100644 index 910a8a83..00000000 --- a/zh-hans/guides/workflow/nodes/end.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: 结束 ---- - -### 定义 - -定义一个工作流程结束的最终输出内容。每一个工作流在完整执行后都需要至少一个结束节点,用于输出完整执行的最终结果。 - -结束节点为流程终止节点,后面无法再添加其他节点,工作流应用中只有运行到结束节点才会输出执行结果。若流程中出现条件分叉,则需要定义多个结束节点。 - -结束节点需要声明一个或多个输出变量,声明时可以引用任意上游节点的输出变量。 - -> **注意** -> Chatflow 内不支持结束节点 - -*** - -### 场景 - -在以下[长故事生成工作流](/zh-hans/guides/workflow/nodes/iteration#示例-2:长文章迭代生成器(另一种编排方式))中,结束节点声明的变量 `Output` 为上游代码节点的输出,即该工作流会在 Code3 节点执行完成之后结束,并输出 Code3 的执行结果。 - -![结束节点-长故事生成示例](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/50152cf67089446181819755a5fa2dcb.png) - -**单路执行示例:** - -![单路执行示例](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/04cddaa15398cd7c905275234494ead7.png) - -**多路执行示例:** - -![多路执行示例](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/3cb3f5fea376265bede0a4ac5bcc1ddc.png) - diff --git a/zh-hans/guides/workflow/nodes/http-request.mdx b/zh-hans/guides/workflow/nodes/http-request.mdx deleted file mode 100644 index c5e436b9..00000000 --- a/zh-hans/guides/workflow/nodes/http-request.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: HTTP 请求 ---- - -### 定义 - -允许通过 HTTP 协议发送服务器请求,适用于获取外部数据、webhook、生成图片、下载文件等情景。它让你能够向指定的网络地址发送定制化的 HTTP 请求,实现与各种外部服务的互联互通。 - -该节点支持常见的 HTTP 请求方法: - -* **GET**,用于请求服务器发送某个资源。 -* **POST**,用于向服务器提交数据,通常用于提交表单或上传文件。 -* **HEAD**,类似于 GET 请求,但服务器不返回请求的资源主体,只返回响应头。 -* **PATCH**,用于在请求-响应链上的每个节点获取传输路径。 -* **PUT**,用于向服务器上传资源,通常用于更新已存在的资源或创建新的资源。 -* **DELETE**,用于请求服务器删除指定的资源。 - -你可以通过配置 HTTP 请求的包括 URL、请求头、查询参数、请求体内容以及认证信息等。 - -![HTTP 请求配置](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/bf2a990493bf60a0278fea7147900fc6.png) - - -*** - -### 场景 - -这个节点的一个实用特性是能够根据场景需要,在请求的不同部分动态插入变量。比如在处理客户评价请求时,你可以将用户名或客户ID、评价内容等变量嵌入到请求中,以定制化自动回复信息或获取特定客户信息并发送相关资源至特定的服务器。 - -![客户评价分类](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/39c7ad0816891caefed1e9446be541bf.png) - -HTTP 请求的返回值包括响应体、状态码、响应头和文件。值得注意的是,如果响应中包含了文件,这个节点能够自动保存文件,供流程后续步骤使用。这样不仅能提高处理效率,也可以更加简单直接地处理带有文件的响应。 - -* **发送文件** - -你可以使用 HTTP PUT 请求将应用内的文件发送至其它 API 服务。在请求的 Body 中,可以在 `binary` 内选中文件变量。这种方式常用于文件传输、文档存储或媒体处理等场景。 - -示例: 假设你正在开发一个文档管理应用,需要将用户上传的 PDF 文件同步发送第三方服务,可以通过 HTTP 请求节点通过文件变量进行传递。 - -配置示例如下: - -![通过 HTTP 节点发送文件](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/7519496a273655476305f26b2fa2321d.png) - -### 高级功能 - -**错误重试** - -针对节点发生的部分异常情况,通常情况下再次重试运行节点即可解决。开启错误重试功能后,节点将在发生错误的时候按照预设策略进行自动重试。你可以调整最大重试次数和每次重试间隔以设置重试策略。 - -- 最大重试次数为 10 次 -- 最大重试间隔时间为 5000 ms - -![错误重试配置](https://assets-docs.dify.ai/2024/12/2e7c6080c0875e31a074c2a9a4543797.png) - -**异常处理** - -HTTP 节点处理信息时有可能会遇到网络请求超时、请求限制等异常情况。应用开发者可以参考以下步骤配置异常分支,在节点出现异常时启用应对方案,而避免中断整个流程。 - -1. 在 HTTP 节点启用 “异常处理” -2. 选择异常处理方案并进行配置 - -需了解更多应对异常的处理办法,请参考[异常处理](/zh-hans/guides/workflow/error-handling/readme)。 - -![异常处理配置](https://assets-docs.dify.ai/2024/12/91daa86d9770390ab2a41d6d0b6ed1e7.png) diff --git a/zh-hans/guides/workflow/nodes/ifelse.mdx b/zh-hans/guides/workflow/nodes/ifelse.mdx deleted file mode 100644 index eeede394..00000000 --- a/zh-hans/guides/workflow/nodes/ifelse.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: 条件分支 ---- - -### 定义 - -根据 If/else/elif 条件将 Chatflow / Workflow 流程拆分成多个分支。 - -### 节点功能 - -条件分支的运行机制包含以下六个路径: - -* IF 条件:选择变量,设置条件和满足条件的值; -* IF 条件判断为 `True`,执行 IF 路径; -* IF 条件判断为 `False`,执行 ELSE 路径; -* ELIF 条件判断为 `True`,执行 ELIF 路径; -* ELIF 条件判断为 `False`,继续判断下一个 ELIF 路径或执行最后的 ELSE 路径; - -**条件类型** - -支持设置以下条件类型: - -* 包含(Contains) -* 不包含(Not contains) -* 开始是(Start with) -* 结束是(End with) -* 是(Is) -* 不是(Is not) -* 为空(Is empty) -* 不为空(Is not empty) - -*** - -### 场景 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/c9655478c988a816a99485f50467049e.png) - -以**文本总结工作流**作为示例说明各个条件: - -* IF 条件: 选择开始节点中的 `summarystyle` 变量,条件为**包含** `技术`; -* IF 条件判断为 `True`,执行 IF 路径,通过知识检索节点查询技术相关知识再到 LLM 节点回复(图中上半部分); -* IF 条件判断为 `False`,但添加了 `ELIF` 条件,即 `summarystyle` 变量输入**不包含**`技术`,但 `ELIF` 条件内包含 `科技`,会检查 `ELIF` 内的条件是否为 `True`,然后执行路径内定义的步骤; -* `ELIF` 内的条件为 `False`,即输入变量既不不包含 `技术`,也不包含 `科技`,继续判断下一个 ELIF 路径或执行最后的 ELSE 路径; -* IF 条件判断为 `False`,即 `summarystyle` 变量输入**不包含** `技术`,执行 ELSE 路径,通过 LLM2 节点进行回复(图中下半部分); - -**多重条件判断** - -涉及复杂的条件判断时,可以设置多重条件判断,在条件之间设置 **AND** 或者 **OR**,即在条件之间取**交集**或者**并集**。 - -![多重条件判断](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/c3bf3ebe6bc8709f5bc5099eb1242845.png) \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/iteration.mdx b/zh-hans/guides/workflow/nodes/iteration.mdx deleted file mode 100644 index edea098d..00000000 --- a/zh-hans/guides/workflow/nodes/iteration.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -title: 迭代 ---- - -### 定义 - -对数组中的元素依次执行相同的操作步骤,直至输出所有结果,可以理解为任务批处理器。迭代节点通常配合数组变量使用。 - -例如在长文翻译迭代节点内,如果将所有内容输入至 LLM 节点,有可能会达到单次对话限制。上游节点可以先将长文拆分为了多个片段,配合迭代节点对各个片段执行批量翻译,以避免达到 LLM 单次对话的消息限制。 - -*** - -### 功能简介 - -使用迭代的条件是确保输入值已格式化为列表对象;迭代节点将依次处理迭代开始节点数组变量内的所有元素,每个元素遵循相同的处理步骤,每轮处理被称为一个迭代,最终输出处理结果。 - -迭代节点的结构通常包含**输入变量**、**迭代工作流**、**输出变量**三个功能单元。 - -**输入变量:** 仅接受 Array 数组变量类型数据。如果你不了解什么是数组变量,请阅读 [扩展阅读:数组](../../../learn-more/extended-reading/what-is-array-variable)。 - -**迭代工作流:** 你可以在迭代节点中使用多个工作流节点,编排不同的任务步骤。 - -**输出变量:** 仅支持输出数组变量 `Array[List]`。如果你想要输出其它变量格式,请阅读 [扩展阅读:如何将数组转换为文本](#如何将数组转换为文本)。 - -![迭代节点原理图](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/2b26dc5f5b088304b65190e14f58423a.png) - -### 场景 - -#### **示例1:长文章迭代生成器** - -![长故事生成器](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/91091e9c5297944edb57f509a7294714.png) - -1. 在 **开始节点** 内添加输入故事标题、大纲变量,提示用户手动输入初始信息 -2. 使用 **LLM 节点** 基于用户输入的故事标题和大纲,让 LLM 开始编写内容 -3. 使用 **参数提取节点** 将 LLM 输出的完整内容转换成数组格式 -4. 通过 **迭代节点** 包裹的 **LLM 节点** 循环多次生成各章节内容 -5. 将 **直接回复** 节点添加在迭代节点内部,实现在每轮迭代生成之后流式输出 - -**具体配置步骤** - -1. 在 **开始节点** 配置故事标题(title)和大纲(outline); - -![开始节点配置](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/1b371ec3fc8a97831745e530fe8ad50f.png) - -2. 选择 **LLM 节点** 基于用户输入的故事标题和大纲,让 LLM 开始编写文本; - -![模板节点](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/55e2b509c4a7b271a71156dc677e6fb8.png) - -3. 选择 **参数提取节点**,将故事文本转换成为数组(Array)结构。提取参数为 `sections` ,参数类型为 `Array[Object]` - -![参数提取](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/89419f8b96db401014ca399e931e61d0.png) - - -参数提取效果受模型推理能力和指令影响,使用推理能力更强的模型,在**指令**内增加示例可以提高参数提取的效果。 - - -4. 将数组格式的故事大纲作为迭代节点的输入,在迭代节点内部使用 **LLM 节点** 进行处理 - -![配置迭代节点](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/eb7735d04b1cb6a6ebde76fe7f0da701.png) - -在 LLM 节点内配置输入变量 `GenerateOverallOutline/output` 和 `Iteration/item` - -![配置 LLM 节点](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/fe17ddf24ec1689be1ab72200804ed0c.png) - - -迭代的内置变量:`items[object]` 和 `index[number]` - -`items[object] 代表以每轮迭代的输入条目;` - -`index[number] 代表当前迭代的轮次;` - - -5. 在迭代节点内部配置 **直接回复节点** ,可以实现在每轮迭代生成之后流式输出。 - -![配置 Answer 节点](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/17fe8533d1649d541e47390db2d1cf92.png) - -6. 完整调试和预览 - -![按故事章节多轮迭代生成](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/a032a01e49387e7bdc2e0038aa3650b3.png) - -#### **示例 2:长文章迭代生成器(另一种编排方式)** - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/6378e5eb85ce9760d7ef642ea555b268.png) - -* 在 **开始节点** 内输入故事标题和大纲 -* 使用 **LLM 节点** 生成文章小标题,以及小标题对应的内容 -* 使用 **代码节点** 将完整内容转换成数组格式 -* 通过 **迭代节点** 包裹的 **LLM 节点** 循环多次生成各章节内容 -* 使用 **模板转换** 节点将迭代节点输出的字符串数组转换为字符串 -* 在最后添加 **直接回复节点** 将转换后的字符串直接输出 - -*** - -### 高级功能 - -**并行模式** - -迭代节点支持并行模式,开启后将有效提升迭代节点的整体运行效率。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/d412f5048cd544b90b829662f64f9593.png) - -下图是迭代节点开启或关闭并行模式的运行效果对比。 - -![顺序与并行执行原理图](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/adbc49bfb14e0de6d1a72ccccc30cdd0.png) - -并行模式下的最高并行轮数为 10,这意味着单位时间内最多可以同时运行 10 个任务。如果需要处理超过 10 个任务,前 10 个元素将率先同时运行,前排任务处理完成后将继续处理剩余任务。 - - -开启并行模式后,不再建议在迭代节点内放置直接回答、变量赋值和工具节点。此举可能会造成异常情况。 - - -* **错误响应方法** - -迭代节点通常需要处理大量任务,有时会在处理某个元素时发生错误。为了避免某个元素异常而中断所有任务,你可以在**错误响应方法**中设置异常的应对方法: - -* 错误时终止。如果发现异常输出,终止迭代节点,输出错误信息。 -* 忽略错误并继续。忽略异常信息,继续处理剩余元素。输出的信息中包含正确信息,异常信息为空值。 -* 移除错误输出。忽略异常信息,继续处理剩余元素。输出的信息中仅包含正确信息。 - -迭代节点的输入变量与输出变量相对应。例如输入变量为 \[1,2,3] ,则输出变量同样为 \[result-1, result-2, result-3]。 - -如果选择了**忽略错误并继续,** 异常情况的输出值为 null 值,例如 \[result-1, null, result-3]; - -如果选择了**移除错误输出,** 将不会输出异常变量,例如 \[result-1, result-3]。 - -### 扩展阅读 - -[**什么是数组变量?**](../../../learn-more/extended-reading/what-is-array-variable) - -*** - -#### 如何生成数组变量? - -你可以通过以下节点生成数组变量,用以充当迭代节点的输入变量: - -* [代码节点](code) - - ![code 节点输出 array](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/2faff6c41d45191307296a52a406b776.png) -* [参数提取](parameter-extractor) - - ![参数提取节点输出 array](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/66ec57db7558ca372fe847834e201a52.png) -* [知识库检索](knowledge-retrieval) -* [迭代](iteration) -* [工具](tools) -* [HTTP 请求](http-request) - -*** - -#### 如何将数组转换为文本 - -迭代节点的输出变量为数组格式,无法直接输出 String 字符串内容。你可以使用一个简单的步骤将数组转换回文本。 - -**使用代码节点转换** - -![代码节点转换](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/d6a2ca50f2484eedea2ff7ca5efb2bb5.png) - -代码示例: - -```python -def main(articleSections: list): - data = articleSections - return { - "result": "\n".join(data) - } -``` - -**使用模板节点转换** - -![模板节点转换](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/ebc414466340c323d2eb1b6c7056360d.png) - -代码示例: - -```django -{{ articleSections | join("\n") }} -``` \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/knowledge-retrieval.mdx b/zh-hans/guides/workflow/nodes/knowledge-retrieval.mdx deleted file mode 100644 index 072c2489..00000000 --- a/zh-hans/guides/workflow/nodes/knowledge-retrieval.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: 知识检索 -version: '简体中文' ---- - - -### 定义 - -从知识库中检索与用户问题相关的文本内容,可作为下游 LLM 节点的上下文来使用。 - -*** - -### 应用场景 - -常见情景:构建基于外部数据/知识的 AI 问答系统(RAG)。了解更多关于 RAG 的[基本概念](../../../learn-more/extended-reading/retrieval-augment/)。 - -下图为一个最基础的知识库问答应用示例,该流程的执行逻辑为:知识库检索作为 LLM 节点的前置步骤,在用户问题传递至 LLM 节点之前,先在知识检索节点内将匹配用户问题最相关的文本内容并召回,随后在 LLM 节点内将用户问题与检索到的上下文一同作为输入,让 LLM 根据检索内容来回复问题。 - -![知识库问答应用示例](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/34eefebfe8737186d89cc3cf2662a99c.png) - -*** - -### 配置指引 - -**配置流程:** - -1. 选择查询变量。查询变量通常代表用户输入的问题,该变量可以作为输入项并检索知识库中的相关文本分段。在常见的对话类应用中一般将开始节点的 `sys.query` 作为查询变量,知识库所能接受的最大查询内容为 200 字符; -2. 选择需要查询的知识库,可选知识库需要在 Dify 知识库内预先[创建](../../knowledge-base/create-knowledge-and-upload-documents/); -3. 在 元数据筛选 板块中配置元数据的筛选条件,使用元数据功能筛选知识库内的文档。详情请参阅[在应用内集成知识库](/zh-hans/guides/knowledge-base/integrate-knowledge-within-application)中的 **使用元数据筛选知识** 章节。 -4. 指定[召回模式](../../../learn-more/extended-reading/retrieval-augment/retrieval)。自 9 月 1 日后,知识库的召回模式将自动切换为多路召回,不再建议使用 N 选 1 召回模式; -5. 连接并配置下游节点,一般为 LLM 节点; - -![知识检索配置](https://assets-docs.dify.ai/2025/03/f33b9a3ff1c9468fb5d7c1de4c1e02d6.png) - -**输出变量** - -![输出变量](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/ca3d688cb8644b6e0e1f7ce54256ee34.png) - -知识检索的输出变量 `result` 为从知识库中检索到的相关文本分段。其变量数据结构中包含了分段内容、标题、链接、图标、元数据信息。 - -**配置下游节点** - -在常见的对话类应用中,知识库检索的下游节点一般为 LLM 节点,知识检索的**输出变量** `result` 需要配置在 LLM 节点中的 **上下文变量** 内关联赋值。关联后你可以在提示词的合适位置插入 **上下文变量**。 - - -上下文变量是 LLM 节点内定义的特殊变量类型,用于在提示词内插入外部检索的文本内容。 - - -当用户提问时,若在知识检索中召回了相关文本,文本内容会作为上下文变量中的值填入提示词,提供 LLM 回复问题;若未在知识库检索中召回相关的文本,上下文变量值为空,LLM 则会直接回复用户问题。 - -![配置下游 LLM 节点](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/a9cb49ad4b8e0dee1f8bb20f49d1fe79.png) - -该变量除了可以作为 LLM 回复问题时的提示词上下文作为外部知识参考引用,另外由于其数据结构中包含了分段引用信息,同时可以支持应用端的 [**引用与归属**](/zh-hans/guides/knowledge-base/retrieval-test-and-citation) 功能。 \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/list-operator.mdx b/zh-hans/guides/workflow/nodes/list-operator.mdx deleted file mode 100644 index 5359a81d..00000000 --- a/zh-hans/guides/workflow/nodes/list-operator.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: 列表操作 -version: '简体中文' ---- - -文件列表变量支持同时上传文档文件、图片、音频与视频文件等多种文件。应用使用者在上传文件时,所有文件都存储在同一个 `Array[File]` 数组类型变量内,**不利于后续单独处理文件。** 列表操作节点可以在数组变量内提取单独的元素,便于后续节点处理。 - -> `Array`数据类型意味着该变量的实际值可能为 \[1.mp3, 2.png, 3.doc],大语言模型(LLM)仅支持读取图片文件或文本内容等单一值作为输入变量,无法直接读取数组变量,通常需要配合列表操作节点一起使用。 - -### 节点功能 - -列表操作节点可以对文件的格式类型、文件名、大小等属性进行过滤与提取,将不同格式的文件传递给对应的处理节点,以实现对不同文件处理流的精确控制。 - -例如在一个应用中,允许用户同时上传文档文件和图片文件两种不同类型的文件。需要使用**列表操作节点**进行分拣,将不同的文件类型交由不同流程处理。 - -![分流不同的文件类型](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/522a0c932aab93d4f3970168412f759e.png) - -列表操作节点一般用于提取数组变量中的信息,通过设置条件将其转化为能够被下游节点所接受的变量类型。它的结构分为**输入变量**、**过滤条件**、**排序(可选)**、**取前 N 项(可选)**、**输出变量**。 - -![列表操作节点](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/8c1be5a1270203aeb694872c316cd61e.png) - -#### 输入变量 - -列表操作节点仅接受以下数据结构变量: - -* Array\[string] -* Array\[number] -* Array\[file] - -#### 过滤条件 - -处理输入变量中的数组,添加过滤条件。从数组中分拣所有满足条件的数组变量,可以理解为对变量的属性进行过滤。 - -举例:文件中可能包含多重维度的属性,例如文件名、文件类型、文件大小等属性。过滤条件允许设置筛选条件,选择并提取数组变量中的特定文件。 - -支持提取以下变量: - -* type 文件类别,包含图片,文档,音频和视频类型 -* size 文件大小 -* name 文件名 -* url 指的是应用使用者通过 URL 上传的文件,可填写完整 URL 进行筛选 -* extension 文件拓展名 -* mime\_type - - [MIME 类型](https://datatracker.ietf.org/doc/html/rfc2046)是用来标识文件内容类型的标准化字符串。示例: "text/html" 表示 HTML 文档。 -* transfer\_method - - 文件上传方式,分为本地上传或通过 URL 上传 - -#### 排序 - -提供对于输入变量中数组的排序能力,支持根据文件属性进行排序。 - -* 升序排列 - - 默认排序选项,按照从小到大排序。对于字母和文本,按字母表顺序排列(A - Z) -* 降序排列 - - 由大到小排序,对于字母和文本,按字母表倒序排列(Z - A) - -该选项常用于配合输出变量中的 first\_record 及 last\_record 使用。 - -#### 取前 N 项 - -可以在 1-20 中选值,用途是为了选中数组变量的前 n 项。 - -#### 输出变量 - -满足各项过滤条件的数组元素。过滤条件、排序和限制可以单独开启。如果同时开启,则返回符合所有条件的数组元素。 - -* Result,过滤结果,数据类型为数组变量。若数组中仅包含 1 个文件,则输出变量仅包含 1 个数组元素; -* first\_record,筛选完的数组的首元素,即 result\[0]; -* last\_record,筛选完的数组的尾元素,即 result\[array.length-1]。 - -*** - -### 配置案例 - -在文件交互问答场景中,应用使用者可能会同时上传文档文件或图片文件。LLM 仅支持识别图片文件的能力,不支持读取文档文件。此时需要用到 [列表操作](list-operator) 节点预处理文件变量的数组,将不同的文件类型并发送至对应的处理节点。编排步骤如下: - -1. 开启 [Features](../additional-feature) 功能,并在文件类型中勾选 "图片" + "文档文件" 类型。 -2. 添加两个列表操作节点,在 "过滤" 条件中分别设置提取图片与文档变量。 -3. 提取文档文件变量,传递至 "文档提取器" 节点;提取图片文件变量,传递至 "LLM" 节点。 -4. 在末尾添加 "直接回复" 节点,填写 LLM 节点的输出变量。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/ca60c2a982f7a9902c178e4e5503db50.png) - -应用使用者同时上传文档文件和图片后,文档文件自动分流至文档提取器节点,图片文件自动分流至 LLM 节点以实现对于混合文件的共同处理。 diff --git a/zh-hans/guides/workflow/nodes/llm.mdx b/zh-hans/guides/workflow/nodes/llm.mdx deleted file mode 100644 index 1bbd8103..00000000 --- a/zh-hans/guides/workflow/nodes/llm.mdx +++ /dev/null @@ -1,158 +0,0 @@ ---- -title: LLM ---- - -### 定义 - -调用大语言模型的能力,处理用户在 "开始" 节点中输入的信息(自然语言、上传的文件或图片),给出有效的回应信息。 - - - LLM 节点 - - -*** - -### 应用场景 - -LLM 节点是 Chatflow/Workflow 的核心节点。该节点能够利用大语言模型的对话/生成/分类/处理等能力,根据给定的提示词处理广泛的任务类型,并能够在工作流的不同环节使用。 - -* **意图识别**,在客服对话情景中,对用户问题进行意图识别和分类,导向下游不同的流程。 -* **文本生成**,在文章生成情景中,作为内容生成的节点,根据主题、关键词生成符合的文本内容。 -* **内容分类**,在邮件批处理情景中,对邮件的类型进行自动化分类,如咨询/投诉/垃圾邮件。 -* **文本转换**,在文本翻译情景中,将用户提供的文本内容翻译成指定语言。 -* **代码生成**,在辅助编程情景中,根据用户的要求生成指定的业务代码,编写测试用例。 -* **RAG**,在知识库问答情景中,将检索到的相关知识和用户问题重新组织回复问题。 -* **图片理解**,使用 vision 能力的多模态模型,能对图像内的信息进行理解和问答。 - -选择合适的模型,编写提示词,你可以在 Chatflow/Workflow 中构建出强大、可靠的解决方案。 - -*** - -### 配置示例 - -在应用编辑页中,点击鼠标右键或轻点上一节点末尾的 + 号,添加节点并选择 LLM。 - - - LLM 节点配置-选择模型 - - -**配置步骤:** - -1. **选择模型**,Dify 提供了全球主流模型的[支持](user-guide/getting-started/readme/model-providers),包括 OpenAI 的 GPT 系列、Anthropic 的 Claude 系列、Google 的 Gemini 系列等,选择一个模型取决于其推理能力、成本、响应速度、上下文窗口等因素,你需要根据场景需求和任务类型选择合适的模型。 - -> 如果你是初次使用 Dify ,在 LLM 节点选择模型之前,需要在 **系统设置—模型供应商** 内提前完成[模型配置](../../model-configuration/)。 - -2. **配置模型参数**,模型参数用于控制模型的生成结果,例如温度、TopP,最大标记、回复格式等,为了方便选择系统同时提供了 3 套预设参数:创意,平衡和精确。如果你对以上参数并不熟悉,建议选择默认设置。若希望应用具备图片分析能力,请选择具备视觉能力的模型。 -3. **填写上下文(可选)**,上下文可以理解为向 LLM 提供的背景信息,常用于填写[知识检索](knowledge-retrieval)的输出变量。 -4. **编写提示词**,LLM 节点提供了一个易用的提示词编排页面,选择聊天模型或补全模型,会显示不同的提示词编排结构。如果选择聊天模型(Chat model),你可以自定义系统提示词(SYSTEM)/用户(USER)/ 助手(ASSISTANT)三部分内容。 - - - 编写提示词 - - -如果在编写系统提示词(SYSTEM)时没有好的思路,也可以使用提示生成器功能,借助 AI 能力快速生成适合实际业务场景的提示词。 - - - 提示生成器 - - -在提示词编辑器中,你可以通过输入 **"/"** 呼出 **变量插入菜单**,将 **特殊变量块** 或者 **上游节点变量** 插入到提示词中作为上下文内容。 - - - 呼出变量插入菜单 - - -5. **高级设置**,可以开关记忆功能并设置记忆窗口、开关 Vision 功能或者使用 Jinja-2 模版语言来进行更复杂的提示词等。 - -*** - -### 特殊变量说明 - -**上下文变量** - -上下文变量是一种特殊变量类型,用于向 LLM 提供背景信息,常用于在知识检索场景下使用。详细说明请参考[知识检索节点](knowledge-retrieval)。 - -**图片文件变量** - -具备视觉能力的 LLM 可以通过变量读取应用使用者所上传的图片。开启 VISION 后,选择图片文件的输出变量完成设置。 - - - 视觉上传功能 - - -**会话历史** - -为了在文本补全类模型(例如 gpt-3.5-turbo-Instruct)内实现聊天型应用的对话记忆,Dify 在原[提示词专家模式(已下线)](user-guide/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/)内设计了会话历史变量,该变量沿用至 Chatflow 的 LLM 节点内,用于在提示词中插入 AI 与用户之间的聊天历史,帮助 LLM 理解对话上文。 - -> 会话历史变量应用并不广泛,仅在 Chatflow 中选择文本补全类模型时可以插入使用。 - - - 插入会话历史变量 - - -**模型参数** - -模型的参数会影响模型的输出效果。不同模型的参数会有所区别。下图为`gpt-4`的参数列表。 - - - 模型参数列表 - - -主要的参数名词解释如下: - -* **温度:** 通常是0-1的一个值,控制随机性。温度越接近0,结果越确定和重复,温度越接近1,结果越随机。 -* **Top P:** 控制结果的多样性。模型根据概率从候选词中选择,确保累积概率不超过预设的阈值P。 -* **存在惩罚:** 用于减少重复生成同一实体或信息,通过对已经生成的内容施加惩罚,使模型倾向于生成新的或不同的内容。参数值增加时,对于已经生成过的内容,模型在后续生成中被施加更大的惩罚,生成重复内容的可能性越低。 -* **频率惩罚:** 对过于频繁出现的词或短语施加惩罚,通过降低这些词的生成概率。随着参数值的增加,对频繁出现的词或短语施加更大的惩罚。较高的参数值会减少这些词的出现频率,从而增加文本的词汇多样性。 - -如果你不理解这些参数是什么,可以选择**加载预设**,从创意、平衡、精确三种预设中选择。 - - - 加载预设参数 - - -*** - -### 高级功能 - -**记忆:** 开启记忆后问题分类器的每次输入将包含对话中的聊天历史,以帮助 LLM 理解上文,提高对话交互中的问题理解能力。 - -**记忆窗口:** 记忆窗口关闭时,系统会根据模型上下文窗口动态过滤聊天历史的传递数量;打开时用户可以精确控制聊天历史的传递数量(对数)。 - -**对话角色名设置:** 由于模型在训练阶段的差异,不同模型对于角色名的指令遵循程度不同,如 Human/Assistant,Human/AI,人类/助手等等。为适配多模型的提示响应效果,系统提供了对话角色名的设置,修改对话角色名将会修改会话历史的角色前缀。 - -**Jinja-2 模板:** LLM 的提示词编辑器内支持 Jinja-2 模板语言,允许你借助 Jinja2 这一强大的 Python 模板语言,实现轻量级数据转换和逻辑处理,参考[官方文档](https://jinja.palletsprojects.com/en/3.1.x/templates/)。 - -*** - -### 使用案例 - -* **读取知识库内容** - -想要让工作流应用具备读取 ["知识库"](/zh-cn/user-guide/knowledge-base/) 内容的能力,例如搭建智能客服应用,请参考以下步骤: - -1. 在 LLM 节点上游添加知识库检索节点; -2. 将知识检索节点的 **输出变量** `result` 填写至 LLM 节点中的 **上下文变量** 内; -3. 将 **上下文变量** 插入至应用提示词内,赋予 LLM 读取知识库内的文本能力。 - - - 上下文变量 - - -[知识检索节点](knowledge-retrieval)输出的变量 `result` 还包含了分段引用信息,你可以通过 [**引用与归属**](/zh-hans/guides/knowledge-base/retrieval-test-and-citation) 功能查看信息来源。 - -> 上游节点的普通变量同样可以填写至上下文变量内,例如开始节点的字符串类型变量,但 **引用与归属** 功能将会失效。 - -* **读取文档文件** - -想要让工作流应用具备读取读取文档内容的能力,例如搭建 ChatPDF 应用,可以参考以下步骤: - -* 在 “开始” 节点内添加文件变量; -* 在 LLM 节点上游添加文档提取器节点,将文件变量作为输入变量; -* 将文档提取器节点的 **输出变量** `text` 填写至 LLM 节点中的提示词内。 - -如需了解更多,请参考[文件上传](/zh-hans/guides/workflow/file-upload)。 - - - 填写系统提示词 - diff --git a/zh-hans/guides/workflow/nodes/loop.mdx b/zh-hans/guides/workflow/nodes/loop.mdx deleted file mode 100644 index 1c85808c..00000000 --- a/zh-hans/guides/workflow/nodes/loop.mdx +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: Loop ---- - -循环(Loop)节点用于执行依赖前一轮结果的重复任务,直到满足退出条件或达到最大循环次数。 - -## 循环节点与迭代节点有什么区别? - -循环节点和迭代节点在任务处理上的定位不同: - - - - - - - - - - - - - - - - - - - - - -
类型特点适用场景
循环(Loop)轮次之间存在依赖关系的优化型任务。即任务的每一轮执行都依赖上一轮的结果。需要前一轮的计算结果,适用于递归、优化问题等。
迭代(Iteration)轮次之间无依赖关系的批处理任务。即每一轮任务可以独立运行,无需依赖前一轮。每轮独立执行,可用于数据批量处理等。
- -## 如何配置循环节点? - -循环节点包含以下两个关键配置项: - - - - - - - - - - - - - - - - - - - - - -
配置项作用示例
循环退出条件(Loop Termination Condition)设置循环何时停止例:当变量 x < 50 时,停止循环。
最大循环次数(Maximum Loop Count)限制最多执行的轮次,避免无限循环例:最多执行 10 轮,不管是否满足退出条件。
- -你可以在 **循环退出条件** 中使用循环体内的变量或会话中的全局变量,让循环按照你的需求停止。 - -![Configuration](https://assets-docs.dify.ai/2025/03/13853bfaaa068cdbdeba1b1f75d482f2.png) - -## 示例:如何使用循环节点? - -**需求:生成 1-100 的随机数,直到随机数小于 50 时停止。** - -**实现步骤**: - -1. 使用 `code` 节点生成 `1-100` 的随机数。 - -2. 使用 `if` 节点判断随机数是否小于 `50`: - - - 如果小于 50,输出 `done` 并结束循环。 - - - 如果不小于 50,继续循环,生成新的随机数。 - -3. 设置循环退出标准:随机数 `< 50`。 - -4. 循环将在随机数小于 `50` 时自动停止。 - -![Case steps](https://assets-docs.dify.ai/2025/03/b1c277001fc3cb1fbb85fe7c22a6d0fc.png) - -## 未来扩展 - -**后续版本将提供:** - -- 循环变量:支持在循环过程中存储和引用变量,增强逻辑控制能力。 - -- `break` 节点:允许在循环体内部直接终止循环,适用于更复杂的流程控制。 diff --git a/zh-hans/guides/workflow/nodes/parameter-extractor.mdx b/zh-hans/guides/workflow/nodes/parameter-extractor.mdx deleted file mode 100644 index 4684c4da..00000000 --- a/zh-hans/guides/workflow/nodes/parameter-extractor.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: 参数提取 ---- - -### 定义 - -利用 LLM 从自然语言推理并提取结构化参数,用于后置的工具调用或 HTTP 请求。 - -Dify 工作流内提供了丰富的[工具](https://docs.dify.ai/v/zh-hans/guides/tools)选择,其中大多数工具的输入为结构化参数,参数提取器可以将用户的自然语言转换为工具可识别的参数,方便工具调用。 - -工作流内的部分节点有特定的数据格式传入要求,如[迭代](/zh-hans/guides/workflow/nodes/iteration)节点的输入要求为数组格式,参数提取器可以方便的实现结构化参数的转换。 - -*** - -### 场景 - -1. **从自然语言中提供工具所需的关键参数提取**,如构建一个简单的对话式 Arxiv 论文检索应用。 - -在该示例中:Arxiv 论文检索工具的输入参数要求为 **论文作者** 或 **论文编号**,参数提取器从问题"这篇论文中讲了什么内容:2405.10739"中提取出论文编号 **2405.10739**,并作为工具参数进行精确查询。 - -![Arxiv 论文检索工具](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/9119e3f40d71ac845ad1e14f7401ee1f.png) - -2. **将文本转换为结构化数据**,如长故事迭代生成应用中,作为[迭代节点](/zh-hans/guides/workflow/nodes/iteration)的前置步骤,将文本格式的章节内容转换为数组格式,方便迭代节点进行多轮生成处理。 - -![长故事迭代生成应用流程图](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/342d37bfa31c1d9ab26cd8212be7ee7d.png) - -3. **提取结构化数据并使用** [**HTTP 请求**](/zh-hans/guides/workflow/nodes/http-request) ,可请求任意可访问的 URL ,适用于获取外部检索结果、webhook、生成图片等情景。 - -*** - -### 3 如何配置 - -![参数提取配置界面](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/2171232dfe8a907ebad05cef8b789c9a.png) - -**配置步骤** - -1. 选择输入变量,一般为用于提取参数的变量输入。输入变量支持 file -2. 选择模型,参数提取器的提取依靠的是 LLM 的推理和结构化生成能力 -3. 定义提取参数,可以手动添加需要提取的参数,也可以**从已有工具中快捷导入** -4. 编写指令,在提取复杂的参数时,编写示例可以帮助 LLM 提升生成的效果和稳定性 - -**高级设置** - -**推理模式** - -部分模型同时支持两种推理模式,通过函数/工具调用或是纯提示词的方式实现参数提取,在指令遵循能力上有所差别。例如某些模型在函数调用效果欠佳的情况下可以切换成提示词推理。 - -* Function Call/Tool Call -* Prompt - -**记忆** - -开启记忆后问题分类器的每次输入将包含对话中的聊天历史,以帮助 LLM 理解上文,提高对话交互中的问题理解能力。 - -**图片** - -开启图片 - -**输出变量** - -* 提取定义的变量 -* 节点内置变量 - -`__is_success Number 提取是否成功` 成功时值为 1,失败时值为 0。 - -`__reason String` 提取错误原因 \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/question-classifier.mdx b/zh-hans/guides/workflow/nodes/question-classifier.mdx deleted file mode 100644 index 4bbf0fd6..00000000 --- a/zh-hans/guides/workflow/nodes/question-classifier.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: 问题分类 ---- - -### **定义** - -通过定义分类描述,问题分类器能够根据用户输入,使用 LLM 推理与之相匹配的分类并输出分类结果,向下游节点提供更加精确的信息。 - -*** - -### **场景** - -常见的使用情景包括**客服对话意图分类、产品评价分类、邮件批量分类**等。 - -在一个典型的产品客服问答场景中,问题分类器可以作为知识库检索的前置步骤,对用户输入问题意图进行分类处理,分类后导向下游不同的知识库查询相关的内容,以精确回复用户的问题。 - -下图为产品客服场景的示例工作流模板: - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/465d730a4b7eaa2005e7268a086bdd1a.png) - -在该场景中我们设置了 3 个分类标签/描述: - -* 分类 1 :**与售后相关的问题** -* 分类 2:**与产品操作使用相关的问题** -* 分类 3 :**其他问题** - -当用户输入不同的问题时,问题分类器会根据已设置的分类标签 / 描述自动完成分类: - -* "**iPhone 14 如何设置通讯录联系人?**" —> "**与产品操作使用相关的问题**" -* "**保修期限是多久?**" —> "**与售后相关的问题**" -* "**今天天气怎么样?**" —> "**其他问题**" - -*** - -### 如何配置 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/923c4cbc6956fe8925895b812802a24b.png) - -**配置步骤:** - -1. **选择输入变量**,指用于分类的输入内容,支持输入[文件变量](/zh-hans/guides/workflow/variables)。客服问答场景下一般为用户输入的问题 `sys.query`; -2. **选择推理模型**,问题分类器基于大语言模型的自然语言分类和推理能力,选择合适的模型将有助于提升分类效果; -3. **编写分类标签/描述**,你可以手动添加多个分类,通过编写分类的关键词或者描述语句,让大语言模型更好的理解分类依据。 -4. **选择分类对应的下游节点,** 问题分类节点完成分类之后,可以根据分类与下游节点的关系选择后续的流程路径。 - -#### **高级设置:** - -**指令:** 你可以在 **高级设置-指令** 里补充附加指令,比如更丰富的分类依据,以增强问题分类器的分类能力。 - -**记忆:** 开启记忆后问题分类器的每次输入将包含对话中的聊天历史,以帮助 LLM 理解上文,提高对话交互中的问题理解能力。 - -**图片分析:** 仅适用于具备图片识别能力的 LLM,允许输入图片变量。 - -**记忆窗口:** 记忆窗口关闭时,系统会根据模型上下文窗口动态过滤聊天历史的传递数量;打开时用户可以精确控制聊天历史的传递数量(对数)。 - -**输出变量:** - -`class_name` 存储了分类模型的预测结果。当分类完成后,这个变量会包含具体的类别标签,你可以在后续的处理节点中引用这个分类结果来执行相应的逻辑。 \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/start.mdx b/zh-hans/guides/workflow/nodes/start.mdx deleted file mode 100644 index 15ec90f6..00000000 --- a/zh-hans/guides/workflow/nodes/start.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: 开始 -version: '简体中文' ---- - -## 定义 - -**"开始"** 节点是每个工作流应用(Chatflow / Workflow)必备的预设节点,为后续工作流节点以及应用的正常流转提供必要的初始信息,例如应用使用者所输入的内容、以及[上传的文件](/zh-hans/guides/workflow/file-upload)等。 - -### 配置节点 - -在开始节点的设置页,你可以看到两部分设置,分别是 **"输入字段"** 和预设的[**系统变量**](/zh-hans/guides/workflow/variables#系统变量)。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/c4a9bb46f636807f0b59710724fddc40.png) - -### 输入字段 - -输入字段功能由应用开发者设置,通常用于让应用使用者主动补全更多信息。例如在周报应用中要求使用者按照格式预先提供更多背景信息,如姓名、工作日期区间、工作详情等。这些前置信息将有助于 LLM 生成质量更高的答复。 - -支持以下六种类型输入变量,所有变量均可设置为必填项: - -* **文本**:短文本,由应用使用者自行填写内容,最大长度 256 字符。 -* **段落**:长文本,允许应用使用者输入较长字符。 -* **下拉选项**:由应用开发者固定选项,应用使用者仅能选择预设选项,无法自行填写内容。 -* **数字**:仅允许用户输入数字。 -* **单文件**:允许应用使用者单独上传文件,支持文档类型文件、图片、音频、视频和其它文件类型。支持通过本地上传文件或粘贴文件 URL。详细用法请参考[文件上传](/zh-hans/guides/workflow/file-upload)。 -* **文件列表**:允许应用使用者批量上传文件,支持文档类型文件、图片、音频、视频和其它文件类型。支持通过本地上传文件或粘贴文件 URL。详细用法请参考[文件上传](/zh-hans/guides/workflow/file-upload)。 - - -Dify 内置的文档提取器节点只能够处理部分格式的文档文件。如需处理图片、音频或视频类型文件,请参考[外部数据工具](/zh-hans/guides/tools/extensions/code-based/external-data-tool)搭建对应文件的处理节点。 - - -配置完成后,用户在使用应用前将按照输入项指引,向 LLM 提供必要信息。更多的信息将有助于 LLM 提升问答效率。 - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/400679ae5cbbcd5dc0f84ec5861efc85.png) - -### 系统变量 - -系统变量指的是在 Chatflow / Workflow 应用内预设的系统级参数,可以被应用内的其它节点全局读取。通常用于进阶开发场景,例如搭建多轮次对话应用、收集应用日志与监控、记录不同应用和用户的使用行为等。 - -**Workflow** - -Workflow 类型应用提供以下系统变量: - -| 变量名称 | 数据类型 | 说明 | 备注 | -|---------|--------|------|------| -| `sys.files` [LEGACY] | Array[File] | 文件参数,存储用户初始使用应用时上传的图片 | 图片上传功能需在应用编排页右上角的 "功能" 处开启 | -| `sys.user_id` | String | 用户 ID,每个用户在使用工作流应用时,系统会自动向用户分配唯一标识符,用以区分不同的对话用户 | | -| `sys.app_id` | String | 应用 ID,系统会向每个 Workflow 应用分配一个唯一的标识符,用以区分不同的应用,并通过此参数记录当前应用的基本信息 | 面向具备开发能力的用户,通过此参数区分并定位不同的 Workflow 应用 | -| `sys.workflow_id` | String | Workflow ID,用于记录当前 Workflow 应用内所包含的所有节点信息 | 面向具备开发能力的用户,可以通过此参数追踪并记录 Workflow 内的包含节点信息 | -| `sys.workflow_run_id` | String | Workflow 应用运行 ID,用于记录 Workflow 应用中的运行情况 | 面向具备开发能力的用户,可以通过此参数追踪应用的历次运行情况 | - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/cb39be409f0037549d45f4b7d05aa9ce.png) - -**Chatflow** - -Chatflow 类型应用提供以下系统变量: - -| 变量名称 | 数据类型 | 说明 | 备注 | -|---------|--------|------|------| -| `sys.query` | String | 用户在对话框中初始输入的内容 | | -| `sys.files` | Array[File] | 用户在对话框内上传的图片 | 图片上传功能需在应用编排页右上角的 "功能" 处开启 | -| `sys.dialogue_count` | Number | 用户在与 Chatflow 类型应用交互时的对话轮数。每轮对话后自动计数增加 1,可以和 if-else 节点搭配出丰富的分支逻辑。例如到第 X 轮对话时,回顾历史对话并给出分析 | | -| `sys.conversation_id` | String | 对话框交互会话的唯一标识符,将所有相关的消息分组到同一个对话中,确保 LLM 针对同一个主题和上下文持续对话 | | -| `sys.user_id` | String | 分配给每个应用用户的唯一标识符,用以区分不同的对话用户 | | -| `sys.app_id` | String | 应用 ID,系统会向每个 Workflow 应用分配一个唯一的标识符,用以区分不同的应用,并通过此参数记录当前应用的基本信息 | 面向具备开发能力的用户,通过此参数区分并定位不同的 Workflow 应用 | -| `sys.workflow_id` | String | Workflow ID,用于记录当前 Workflow 应用内所包含的所有节点信息 | 面向具备开发能力的用户,可以通过此参数追踪并记录 Workflow 内的包含节点信息 | -| `sys.workflow_run_id` | String | Workflow 应用运行 ID,用于记录 Workflow 应用中的运行情况 | 面向具备开发能力的用户,可以通过此参数追踪应用的历次运行情况 | - -![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workflow/node/233efef6802ae700489f3ab3478bca6b.png) \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/template.mdx b/zh-hans/guides/workflow/nodes/template.mdx deleted file mode 100644 index 52d34759..00000000 --- a/zh-hans/guides/workflow/nodes/template.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: 模板转换 -version: '简体中文' ---- - -### 定义 - -允许借助 Jinja2 的 Python 模板语言灵活地进行数据转换、文本处理等。 - -### 什么是 Jinja? - -> Jinja is a fast, expressive, extensible templating engine. -> -> Jinja 是一个快速、表达力强、可扩展的模板引擎。 - -—— [https://jinja.palletsprojects.com/en/3.1.x/](https://jinja.palletsprojects.com/en/3.1.x/) - -### 场景 - -模板节点允许你借助 Jinja2 这一强大的 Python 模板语言,在工作流内实现轻量、灵活的数据转换,适用于文本处理、JSON 转换等情景。例如灵活地格式化并合并来自前面步骤的变量,创建出单一的文本输出。这非常适合于将多个数据源的信息汇总成一个特定格式,满足后续步骤的需求。 - -**示例1:** 将多个输入(文章标题、介绍、内容)拼接为完整文本 - - - 拼接文本示例 - - -**示例2:** 将知识检索节点获取的信息及其相关的元数据,整理成一个结构化的 Markdown 格式 - -```Plain -{% for item in chunks %} -### Chunk {{ loop.index }}. -### Similarity: {{ item.metadata.score | default('N/A') }} - -#### {{ item.title }} - -##### Content -{{ item.content | replace('\n', '\n\n') }} - ---- -{% endfor %} -``` - - - 知识检索节点输出转换为 Markdown示例 - - -你可以参考 Jinja 的[官方文档](https://jinja.palletsprojects.com/en/3.1.x/templates/),创建更为复杂的模板来执行各种任务。 \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/tools.mdx b/zh-hans/guides/workflow/nodes/tools.mdx deleted file mode 100644 index 55753f75..00000000 --- a/zh-hans/guides/workflow/nodes/tools.mdx +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: 工具 ---- - -"工具"节点可以为工作流提供强大的第三方能力支持,分为以下三种类型: - -* **内置工具**,Dify 第一方提供的工具,使用该工具前可能需要先给工具进行 **授权**。 -* **自定义工具**,通过 [OpenAPI/Swagger 标准格式](https://swagger.io/specification/)导入或配置的工具。如果内置工具无法满足使用需求,你可以在 **Dify 菜单导航 --工具** 内创建自定义工具。 -* **工作流**,你可以编排一个更复杂的工作流,并将其发布为工具。详细说明请参考[工具配置说明](/zh-hans/guides/tools/extensions/api-based/api-based-extension)。 - -### 添加并使用工具节点 - -添加节点时,选择右侧的 "工具" tab 页。配置工具节点一般分为两个步骤: - -1. 对工具授权/创建自定义工具/将工作流发布为工具 -2. 配置工具输入和参数 - - - 工具选择 - - -工具节点可以连接其它节点,通过[变量](/zh-hans/guides/workflow/variables)处理和传递数据。 - - - 配置 Google 搜索工具检索外部知识 - - -### 高级功能 - -**错误重试** - -针对节点发生的部分异常情况,通常情况下再次重试运行节点即可解决。开启错误重试功能后,节点将在发生错误的时候按照预设策略进行自动重试。你可以调整最大重试次数和每次重试间隔以设置重试策略。 - -- 最大重试次数为 10 次 -- 最大重试间隔时间为 5000 ms - - - 错误重试配置 - - -**异常处理** - -工具节点处理信息时有可能会遇到异常情况,导致流程中断。应用开发者可以参考以下步骤配置异常分支,在节点出现异常时启用应对方案,而避免中断整个流程。 - -1. 在工具节点启用 "异常处理" -2. 选择异常处理方案并进行配置 - - - 异常处理配置 - - -需了解更多应对异常的处理办法,请参考[异常处理](/zh-hans/guides/workflow/error-handling/readme)。 - -### 将工作流应用发布为工具 - -工作流应用可以被发布为工具,并被其它工作流内的节点所应用。关于如何创建自定义工具和配置工具,请参考[工具配置说明](/zh-hans/guides/tools/extensions/api-based/api-based-extension)。 \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/variable-aggregator.mdx b/zh-hans/guides/workflow/nodes/variable-aggregator.mdx deleted file mode 100644 index 062e2633..00000000 --- a/zh-hans/guides/workflow/nodes/variable-aggregator.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: 变量聚合 ---- - -### 定义 - -将多路分支的变量聚合为一个变量,以实现下游节点统一配置。 - -变量聚合节点(原变量赋值节点)是工作流程中的一个关键节点,它负责整合不同分支的输出结果,确保无论哪个分支被执行,其结果都能通过一个统一的变量来引用和访问。这在多分支的情况下非常有用,可将不同分支下相同作用的变量映射为一个输出变量,避免下游节点重复定义。 - -*** - -### 场景 - -通过变量聚合,可以将诸如问题分类或条件分支等多路输出聚合为单路,供流程下游的节点使用和操作,简化了数据流的管理。 - -**问题分类后的多路聚合** - -未添加变量聚合,分类1 和 分类 2 分支经不同的知识库检索后需要重复定义下游的 LLM 和直接回复节点。 - - - 问题分类无变量聚合的流程图 - - -添加变量聚合,可以将两个知识检索节点的输出聚合为一个变量。 - - - 问题分类后添加变量聚合的流程图 - - -**IF/ELSE 条件分支后的多路聚合** - - - IF/ELSE 条件分支后添加变量聚合的流程图 - - -### 格式要求 - -变量聚合器支持聚合多种数据类型,包括字符串(`String`)、数字(`Number`)、文件(`File`)对象(`Object`)以及数组(`Array`) - -**变量聚合器只能聚合同一种数据类型的变量**。若第一个添加至变量聚合节点内的变量数据格式为 `String`,后续连线时会自动过滤可添加变量为 `String` 类型。 - -**聚合分组** - -开启聚合分组后,变量聚合器可以聚合多组变量,各组内聚合时要求同一种数据类型。 \ No newline at end of file diff --git a/zh-hans/guides/workflow/nodes/variable-assigner.mdx b/zh-hans/guides/workflow/nodes/variable-assigner.mdx deleted file mode 100644 index a653d1cc..00000000 --- a/zh-hans/guides/workflow/nodes/variable-assigner.mdx +++ /dev/null @@ -1,167 +0,0 @@ ---- -title: 变量赋值 -version: '简体中文' ---- - -### 定义 - -变量赋值节点用于向可写入变量进行变量赋值,已支持以下可写入变量: - -* [会话变量](../variables#会话变量)。 - -用法:通过变量赋值节点,你可以将工作流内的变量赋值到会话变量中用于临时存储,并可以在后续对话中持续引用。 - - - 会话变量示例图 - - -*** - -### 使用场景示例 - -通过变量赋值节点,你可以将会话过程中的**上下文、上传至对话框的文件(即将上线)、用户所输入的偏好信息**等写入至会话变量,并在后续对话中引用已存储的信息导向不同的处理流程或者进行回复。 - -**场景 1** - -**自动判断提取并存储对话中的信息**,在会话内通过会话变量数组记录用户输入的重要信息,并在后续对话中让 LLM 基于会话变量中存储的历史信息进行个性化回复。 - -示例:开始对话后,LLM 会自动判断用户输入是否包含需要记住的事实、偏好或历史记录。如果有,LLM 会先提取并存储这些信息,然后再用这些信息作为上下文来回答。如果没有新的信息需要保存,LLM 会直接使用自身的相关记忆知识来回答问题。 - - - 自动判断提取并存储对话中的信息流程图 - - -**配置流程:** - -1. **设置会话变量**:首先设置一个会话变量数组 `memories`,类型为 array\[object],用于存储用户的事实、偏好和历史记录。 -2. **判断和提取记忆**: - * 添加一个条件判断节点,使用 LLM 来判断用户输入是否包含需要记住的新信息。 - * 如果有新信息,走上分支,使用 LLM 节点提取这些信息。 - * 如果没有新信息,走下分支,直接使用现有记忆回答。 -3. **变量赋值/写入**: - * 在上分支中,使用变量赋值节点,将提取出的新信息追加(append)到 `memories` 数组中。 - * 使用转义功能将 LLM 输出的文本字符串转换为适合存储在 array\[object] 中的格式。 -4. **变量读取和使用**: - * 在后续的 LLM 节点中,将 `memories` 数组中的内容转换为字符串,并插入到 LLM 的提示词 Prompts 中作为上下文。 - * LLM 使用这些历史信息来生成个性化回复。 - -图中的 code 节点代码如下: - -1. 将字符串转义为 object - -```python -import json - -def main(arg1: str) -> object: - try: - # Parse the input JSON string - input_data = json.loads(arg1) - - # Extract the memory object - memory = input_data.get("memory", {}) - - # Construct the return object - result = { - "facts": memory.get("facts", []), - "preferences": memory.get("preferences", []), - "memories": memory.get("memories", []) - } - - return { - "mem": result - } - except json.JSONDecodeError: - return { - "result": "Error: Invalid JSON string" - } - except Exception as e: - return { - "result": f"Error: {str(e)}" - } -``` - -2. 将 object 转义为字符串 - -```python -import json - -def main(arg1: list) -> str: - try: - # Assume arg1[0] is the dictionary we need to process - context = arg1[0] if arg1 else {} - - # Construct the memory object - memory = {"memory": context} - - # Convert the object to a JSON string - json_str = json.dumps(memory, ensure_ascii=False, indent=2) - - # Wrap the JSON string in tags - result = f"{json_str}" - - return { - "result": result - } - except Exception as e: - return { - "result": f"Error: {str(e)}" - } -``` - -**场景 2** - -**记录用户的初始偏好信息**,在会话内记住用户输入的语言偏好,在后续对话中持续使用该语言类型进行回复。 - -示例:用户在对话开始前,在 `language` 输入框内指定了 "中文",该语言将会被写入会话变量,LLM 在后续进行答复时会参考会话变量中的信息,在后续对话中持续使用"中文"进行回复。 - - - 记录用户的初始偏好信息流程图 - - -**配置流程:** - -**设置会话变量**:首先设置一个会话变量 `language`,在会话流程开始时添加一个条件判断节点,用来判断 `language` 变量的值是否为空。 - -**变量写入/赋值**:首轮对话开始时,若 `language` 变量值为空,则使用 LLM 节点来提取用户输入的语言,再通过变量赋值节点将该语言类型写入到会话变量 `language` 中。 - -**变量读取**:在后续对话轮次中 `language` 变量已存储用户语言偏好。在后续对话中,LLM 节点通过引用 language 变量,使用用户的偏好语言类型进行回复。 - -**场景 3** - -**辅助 Checklist 检查**,在会话内通过会话变量记录用户的输入项,更新 Checklist 中的内容,并在后续对话中检查遗漏项。 - -示例:开始对话后,LLM 会要求用户在对话框内输入 Checklist 所涉及的事项,用户一旦提及了 Checklist 中的内容,将会更新并存储至会话变量内。LLM 会在每轮对话后提醒用户继续补充遗漏项。 - - - 辅助 Checklist 检查流程图 - - -**配置流程:** - -* **设置会话变量:** 首先设置一个会话变量 `ai_checklist`,在 LLM 内引用该变量作为上下文进行检查。 -* **变量赋值/写入:** 每一轮对话时,在 LLM 节点内检查 `ai_checklist` 内的值并比对用户输入,若用户提供了新的信息,则更新 Checklist 并将输出内容通过变量赋值节点写入到 `ai_checklist` 内。 -* **变量读取:** 每一轮对话读取 `ai_cheklist` 内的值并比对用户输入直至所有 checklist 完成。 - -*** - -### 使用变量赋值节点 - -点击节点右侧 + 号,选择"变量赋值"节点,填写"赋值的变量"和"设置变量"。 - - - 变量赋值节点设置界面 - - -**设置变量:** - -赋值的变量:选择被赋值变量,即指定需要被赋值的目标会话变量。 - -设置变量:选择需要赋值的变量,即指定需要被转换的源变量。 - -以上图赋值逻辑为例:将上一个节点的文本输出项 `Language Recognition/text` 赋值到会话变量 `language` 内。 - -**写入模式:** - -* 覆盖,将源变量的内容覆盖至目标会话变量 -* 追加,指定变量为 Array 类型时 -* 清空,清空目标会话变量中的内容 \ No newline at end of file diff --git a/zh-hans/guides/workflow/shortcut-key.mdx b/zh-hans/guides/workflow/shortcut-key.mdx index 3ab4a19c..0d4752e0 100644 --- a/zh-hans/guides/workflow/shortcut-key.mdx +++ b/zh-hans/guides/workflow/shortcut-key.mdx @@ -9,7 +9,7 @@ Chatflow / Workflow 应用编排页支持以下快捷键,帮助你提升编排 | Ctrl + C | Command + C | 复制节点 | | Ctrl + V | Command + V | 粘贴节点 | | Ctrl + D | Command + D | 复制并新建节点 | -| Ctrl + O | Command + O | 管理节点 | +| Ctrl + O | Command + O | 整理节点 | | Ctrl + Z | Command + Z | 撤销 | | Ctrl + Y | Command + Y | 重做 | | Ctrl + Shift + Z | Command + Shift + Z | 重做 | diff --git a/zh-hans/guides/workspace/app.mdx b/zh-hans/guides/workspace/app.mdx index c38b2ec7..23e965ea 100644 --- a/zh-hans/guides/workspace/app.mdx +++ b/zh-hans/guides/workspace/app.mdx @@ -2,17 +2,17 @@ title: 发现 --- -## 模版应用 +## 模板应用 -在**发现**中,提供了一些常用的模版应用。这些应用涵盖了人力资源,助手,翻译,编程和写作。 +在**发现**中,提供了一些常用的模板应用。这些应用涵盖了人力资源,助手,翻译,编程和写作。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workspace/37573570e27ed988331fee18a7a30ce1.png) -如果要使用某个模版应用,点击模版的“添加到工作区”按钮。在左侧的工作区中,可以使用该应用。 +如果要使用某个模板应用,点击模板的“添加到工作区”按钮。在左侧的工作区中,可以使用该应用。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/guides/workspace/3688257e46ca0ec4e9c23dbe19653d20.png) -如果要修改某个模版来创建一个新的应用,点击模版的“自定义”按钮。 +如果要修改某个模板来创建一个新的应用,点击模板的“自定义”按钮。 ## 工作区 diff --git a/zh-hans/guides/workspace/readme.mdx b/zh-hans/guides/workspace/readme.mdx index 4ceb9a7a..1ca02c0a 100644 --- a/zh-hans/guides/workspace/readme.mdx +++ b/zh-hans/guides/workspace/readme.mdx @@ -6,14 +6,14 @@ Dify 是一个多用户平台,工作空间(Workspace)是团队的基本协 ### 登录方式 -需要注意,目前 Dify 的云服务与社区版支持的登录方式有所区别,参见下表。 +需要注意,目前 Dify 的云服务、社区版、企业版支持的登录方式有所区别,参见下表。 -| | 云服务 | 社区版 | -| -------------- | ---- | ---- | -| Email 登录 | 不支持 | 支持 | -| 使用 GitHub 账号登录 | 支持 | 不支持 | -| 使用 Google 账号登录 | 支持 | 不支持 | -| SSO 登录 | 计划支持 | 计划支持 | +| | 社区版 | 云服务 | 企业版 | +|----------------------|:------:|:------:|:------:| +| Email 登录 | 支持 | - | 支持 | +| 使用 GitHub 账号登录 | - | 支持 | - | +| 使用 Google 账号登录 | - | 支持 | - | +| SSO 登录 | - | - | 支持 | ### 创建账号 diff --git a/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/README.mdx b/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/README.mdx index 7ee517e5..d720a056 100644 --- a/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/README.mdx +++ b/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/README.mdx @@ -2,7 +2,6 @@ title: 提示词专家模式(已下线) --- - 在 Dify 创建应用的编排默认为**简易模式**,这很适合想要快速创建应用的非技术人员,比如你想创建一个企业知识库 Chatbot 或者文章摘要生成器,利用**简易模式**编排对话前提示词,添加变量,添加上下文等简易步骤即可发布一个完整的应用(可参考👉[conversation-application.md](../../../../guides/application-orchestrate/conversation-application.md "mention"))。 而如果你是一个熟练掌握使用 **OpenAI** 的 **Playground** 的技术人员,正想创建一个学习导师应用,需要在提示词中针对不同的教学模块位置嵌入不同的上下文和变量,就可以选择**专家模式。在此模式下你可以自由地编写完整的提示词,包括修改内置的提示词,调整上下文和聊天历史内容在提示词中的位置,设定必要参数等。如果你对 Chat 和 Complete 两种模型不陌生,现在专家模式**可以快速切换 Chat 和Complete 模型以满足你的需要,并且都适用于对话型应用和文本生成型应用。 @@ -35,9 +34,9 @@ title: 提示词专家模式(已下线) * 会话历史仅在对话型应用的文本补全模型中可用。在对话型应用中多次对话时,Dify 会将历史的对话记录根据内置规则进行组装拼接,并替换 `会话历史` 变量。其中 Human 和 Assistant 前缀可点击 `会话历史` 后的`...` 进行修改。 -* **初始模版** +* **初始模板** - 在**专家模式**下,正式编排之前,提示词框会给到一个初始模版,我们可以直接修改初始模版来对 LLM有更加定制化的要求。注意:不同类型应用的不同类型模式下有所区别。 + 在**专家模式**下,正式编排之前,提示词框会给到一个初始模板,我们可以直接修改初始模板来对 LLM有更加定制化的要求。注意:不同类型应用的不同类型模式下有所区别。 具体请参考👉[prompt-engineering-template.md](prompt-engineering-template.md "mention") @@ -117,7 +116,7 @@ Assistant1: 土是黄色的 ### 5. 输入对话前提示词 -系统的提示词初始模版提供了必要的参数和 LLM 回复要求,详情见👉:[prompt-engineering-template.md](prompt-engineering-template.md "mention")。 +系统的提示词初始模板提供了必要的参数和 LLM 回复要求,详情见👉:[prompt-engineering-template.md](prompt-engineering-template.md "mention")。 而开发人员前期编排的核心是对话前提示词(`Pre-prompt`),需要编辑后插入内置提示词,建议的插入位置如下(以创建 “iPhone 咨询客服”为例): @@ -134,7 +133,7 @@ And answer according to the language of the user's question. 注意:你目前掌握的只是一部分 iPhone 型号,而不是全部。 ``` -当然,你也可以定制化修改提示词初始模版,比如你希望 LLM 回复的语言都是英文,你可以将上述的内置提示词修改为: +当然,你也可以定制化修改提示词初始模板,比如你希望 LLM 回复的语言都是英文,你可以将上述的内置提示词修改为: ``` When answer to user: diff --git a/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/prompt-engineering-template.mdx b/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/prompt-engineering-template.mdx index cb2edb5f..198411ee 100644 --- a/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/prompt-engineering-template.mdx +++ b/zh-hans/learn-more/extended-reading/prompt-engineering/prompt-engineering-1/prompt-engineering-template.mdx @@ -1,10 +1,10 @@ --- -title: 提示词初始模版参考 +title: 提示词初始模板参考 --- -为了实现对 LLM 更加定制化的要求来满足开发人员的需要,Dify 在**专家模式**下将内置的完整提示词完全开放,并在编排界面提供了初始模版。以下是四种初始模版参考: +为了实现对 LLM 更加定制化的要求来满足开发人员的需要,Dify 在**专家模式**下将内置的完整提示词完全开放,并在编排界面提供了初始模板。以下是四种初始模板参考: -### 1. 使用聊天模型构建对话型应用模版 +### 1. 使用聊天模型构建对话型应用模板 * **SYSTEM** @@ -41,7 +41,7 @@ And answer according to the language of the user's question. * 预编排提示词(`Pre-prompt`) * 查询变量(`Query`) -### 2. 使用聊天模型构建文本生成型应用模版 +### 2. 使用聊天模型构建文本生成型应用模板 * **SYSTEM** @@ -78,7 +78,7 @@ And answer according to the language of the user's question. * 预编排提示词(`Pre-prompt`) * 查询变量(`Query`) -### 3. 使用文本补全模型构建对话型应用模版 +### 3. 使用文本补全模型构建对话型应用模板 ```Python Use the following context as your learned knowledge, inside XML tags. @@ -114,7 +114,7 @@ Assistant: * 会话历史(`History`) * 查询变量(`Query`) -### 4. 使用文本补全模型构建文本生成型应用模版 +### 4. 使用文本补全模型构建文本生成型应用模板 ```Python Use the following context as your learned knowledge, inside XML tags. @@ -140,7 +140,7 @@ And answer according to the language of the user's question. * 查询变量(`Query`) -Dify 与部分模型厂商针对系统提示词做了联合深度优化,部分模型下的初始模版可能与以上示例不同。 +Dify 与部分模型厂商针对系统提示词做了联合深度优化,部分模型下的初始模板可能与以上示例不同。 ### 参数释义 diff --git a/zh-hans/learn-more/faq/plugins.mdx b/zh-hans/learn-more/faq/plugins.mdx index d93a8d56..fedb64c1 100644 --- a/zh-hans/learn-more/faq/plugins.mdx +++ b/zh-hans/learn-more/faq/plugins.mdx @@ -12,3 +12,5 @@ title: 插件 解决办法:在 `.env` 配置文件的末尾添加 `FORCE_VERIFYING_SIGNATURE=false` 字段即可解决该问题。添加该字段后,Dify 平台将允许安装所有未在 Dify Marketplace 上架(审核)的插件,可能存在安全隐患。 建议在测试 / 沙箱环境内安装插件,确认安全后再安装至生产环境。 + +如果你希望采取更加严格的措施控制插件的安装,请参考[第三方签名验证](/zh_hans/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification.mdx)。 diff --git a/zh-hans/learn-more/use-cases/building-an-ai-thesis-slack-bot.mdx b/zh-hans/learn-more/use-cases/building-an-ai-thesis-slack-bot.mdx new file mode 100644 index 00000000..ffc96d84 --- /dev/null +++ b/zh-hans/learn-more/use-cases/building-an-ai-thesis-slack-bot.mdx @@ -0,0 +1,136 @@ +--- +title: 在 Dify 云端构建 AI Thesis Slack Bot +--- + +> 作者:Alec Lee。2025/03/11 + +## 1. 概述 + +随着信息时代的发展,学术研究的数量不断增长,研究人员需要更高效的方式获取最新的学术成果。AI Thesis Slack Bot 通过 AI 自动化工作流,帮助用户在 Slack 上快速获取 arXiv 论文的摘要。 + +它可以用于: + +* 研究团队获取最新学术动态 +* 公司 AI 研究部门内部信息同步 +* 高校师生进行科研协作等场景需求 + +本指南将向您介绍如何搭建 AI Thesis Slack Bot,其核心工作原理,以及如何高效利用它提高生产力。 + +## 2. 准备工作 + +### 2.1 配置 OpenAI API + +* 在帐户下的模型设置里配置 OpenAI 并安装 API 密钥。 + +![API](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/001API.jpg) + +### 2.2 安装 ArXiv 和 Slack 插件 + +* 在 Dify 的工具里安装 **ArXiv** 和 **Slack**。 + +Slack ArXiv + +### 2.3 Slack 账户创建 + +* 在 [Slack 官方网站](https://slack.com/intl/en-gb/get-started?entry_point=help_center#/createnew) 创建一个免费的 Slack 账户。 + +![Slack](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/003SlackAccount.jpg) + +## 3. AI Thesis Slack Bot 的工作流搭建 + +a.用户在 Dify AI Thesis Slack Bot 里输入关键词(如"Large Language Model")。 + +b.机器人从 arXiv 检索相关论文,筛选最新的研究成果(例2024 年 1 月 1 日后的论文)。 + +c.使用 GPT-4o 进行智能整理,读取论文并生成摘要,推送到 Slack 指定的 Channel 里,格式如下: + +* 📄 论文标题 +* 👤 作者 +* 📆 发布日期 +* 📌 核心内容概述 + +d.机器人自动将摘要推送到 Slack,团队成员可以第一时间在 Slack 频道或私聊中查看最新的论文信息。 + + +## 4. 具体步骤 + +#### 4.1 创建工作流 + +a.在 Dify 主页面 选择 Create from Blank,然后选择 Workflow,输入名称(AI Thesis Slack Bot)。 + +![Create from Blank](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/004Createfromblank.jpg) + + b.在 Tools 里 选择已安装好的 ArXiv Search。 + +![Tools ArXiv](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/005ToolsArXiv.jpg) + +c.在节点里选择 LLM,并设置已配置好的 OpenAI 模型。 + +![LLM](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/006LLM.jpg) + +d.在 Tools 里 选择已安装的 Slack Incoming Webhook 并点击 Authorize,添加 Slack Webhook URL。 + +![Slack Incoming Webhook](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/007Slackincomingwebhook.jpg) + +#### 4.2 添加 Slack Webhook URL + +a.进入 [Slack API 管理页面](https://api.slack.com/apps),点击 **Create New App**(创建新应用)。 + +![Slack API](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/008Slackapi.jpg) + +b.选择 "From scratch"(从零开始),输入应用名称(如 AI Thesis Bot),选择要发送消息的 Slack 频道。 + +![From Scratch](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/009Fromscratch.jpg) + +c.进入 Incoming Webhooks,激活 Activate Incoming Webhooks。点击 Add New Webhook to Workspace,选择 Slack 频道,复制生成的 Webhook URL。 + +![Incoming Webhooks Activate](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/010IncomingwebhooksActivate.jpg) + +d.粘贴 Webhook URL 到 Slack 节点 的 Slack Webhook URL 位置。 + +![Slack Webhook URL](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/011SlackWehookURL.jpg) + +e.选择工作流最后一个节点End后,整理工作节点组建都链接好了。下面就需要配置各个节点上的参数。 + +![End](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/012End.jpg) + +#### 4.3 配置各个节点的参数 + +a.Start 节点:设置关键词查询参数。 + +![Start](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/013StartNode.jpg) + +b.ArXiv Search 节点:添加 Query String 内容(可按需求调整)。 + +ArXiv Search + +c.LLM 节点:选择模型,添加 CONTEXT,在 SYSTEM 里进行 Prompt Engineering(可按需求定制),在 USER 里选择 Context. + +![LLM Context](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/015LLMcontext.jpg) + +d.Slack 节点:在 Content 里选择 LLM/Text String。 + +![Slack Content](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/016SlackEndP.jpg) + +#### 4.4 测试和发布 + +a.在发布前 **试运行**,确认工作流程是否跑通后,点击 发布。 + +![Shiyunxing](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/018TestInupt.jpg) + +b. 如果确认到 Dify 的搜索结果和 Slack 上的传输内容,恭喜您,跑通了。 + +![Last P](https://raw.githubusercontent.com/aleclee1005/MyPic/refs/heads/img/019LastPTest.jpg) + +## 5. 未来优化方向 + +目前,AI Thesis Slack Bot 主要专注于 arXiv 论文检索和摘要推送,后续可以优化: +✅ 提高摘要质量:改进 LLM Prompt 提高精准度。 +✅ 积累检索结果:建立数据库存储历史论文。 +✅ 扩展更多数据源:支持 IEEE、Springer、ACL 等。 +✅ 个性化推荐:基于用户兴趣推送相关论文。 +✅ 多平台支持:兼容 WhatsApp、Teams、WeChat 等。 + +## 6. 结语 + +通过 AI Thesis Slack Bot,您可以实现学术信息的智能自动化推送,提升研究团队的生产力。如果希望进一步探索 AI Thesis Bot 的潜能,可以结合 Dify 和 Realtime API,开发更高级的应用,如 实时论文讨论 和 智能问答,让 AI 在学术交流和 AI 应用中发挥更大作用! 🚀 diff --git a/zh-hans/learn-more/use-cases/connect-dify-to-various-im-platforms-by-using-langbot.mdx.mdx b/zh-hans/learn-more/use-cases/connect-dify-to-various-im-platforms-by-using-langbot.mdx.mdx new file mode 100644 index 00000000..f7f649f3 --- /dev/null +++ b/zh-hans/learn-more/use-cases/connect-dify-to-various-im-platforms-by-using-langbot.mdx.mdx @@ -0,0 +1,105 @@ +--- +title: 将 Dify 快速接入 QQ、微信、飞书、钉钉等平台 +--- + +## 1. 概述 + +市面上有多种多样的 IM 平台,接入机器人的方法各不相同,使用难度也参差不齐,导致难以快速接入 Dify 等 LLMOps 平台,使用 Dify 的强大生态。而借助 [LangBot](https://github.com/RockChinQ/LangBot),即可在短时间内将 Dify 接入到 QQ、微信、飞书、钉钉、Telegram、Discord 等平台提供服务。同时,LangBot 还提供扩展机制和丰富的生态,能更加灵活地满足需求。 + +## 2. 部署 LangBot + +### 2.1. 部署 LangBot + +你可以通过以下三种方式部署 LangBot: + +1. Docker 部署:[对应链接](https://docs.langbot.app/deploy/langbot/docker.html) +2. 手动部署:[对应链接](https://docs.langbot.app/deploy/langbot/one-click/bt.html) +3. 使用宝塔面板部署:[对应链接](https://docs.langbot.app/deploy/langbot/manual.html) + +### 2.2. 对接消息平台 + +参考[此页面](https://docs.langbot.app/deploy/platforms/readme.html),选择你要用的消息平台,如 QQ、微信、飞书、钉钉、Telegram、Discord等 + +## 3. 接入 Dify + +在首次运行 LangBot 后,会在 LangBot 目录生成 data 文件夹,打开其中的 `config/provider.json` 文件,设置其中的 `runner` 为 `dify-service-api`。 + +```json +"runner": "dify-service-api", +``` + +相应的,配置 `dify-service-api`: + +```json + "dify-service-api": { + "base-url": "https://api.dify.ai/v1", + "app-type": "chat", + "options": { + "convert-thinking-tips": "original" + }, + "chat": { + "api-key": "app-1234567890", + "timeout": 120 + }, + "agent": { + "api-key": "app-1234567890", + "timeout": 120 + }, + "workflow": { + "api-key": "app-1234567890", + "output-key": "summary", + "timeout": 120 + } + } +``` + +- `base-url`:Dify Service API 的地址,默认是 `https://api.dify.ai/v1`,这是 Dify 官方云服务的地址,如果你使用的是自部署的社区版,请设置为你的自部署地址。 + +- `app-type`:使用的 Dify 应用类型。支持 `chat` - 聊天助手(含 Chatflow)、 `agent` - Agent、 `workflow` - 工作流;请填写下方对应的应用类型 API 参数 + +- `options`:特殊的选项配置。 + - `convert-thinking-tips`:dify 使用 deepseek-r1 等有思维链的模型时[会携带思考过程回复](https://github.com/RockChinQ/LangBot/issues/1108),此选项控制输出时的处理方式;值为 original 时,不转换思考提示;值为 plain 时,将思考提示转换为类似 DeepSeek 官方的...格式;值为 remove 时,删除思考提示 + +- + chat:Dify 聊天助手(或 chatflow)应用的配置 + + - `api-key`:Dify 聊天助手应用的 API 密钥 + - `timeout`:Dify 聊天助手应用的请求超时时间,以秒为单位,默认是 120 秒。 + +- + agent:Dify Agent 应用的配置 + + - `api-key`:Dify Agent 应用的 API 密钥 + - `timeout`:Dify Agent 应用的请求超时时间,以秒为单位,默认是 120 秒。 + +- + workflow:Dify 工作流应用的配置 + + - `api-key`:Dify 工作流应用的 API 密钥 + - `output-key`:Dify 工作流应用的输出键,用于获取工作流应用的输出结果。默认为`summary`,对应工作流编排时,end节点的输出变量。 + - `timeout`:Dify 工作流应用的请求超时时间,以秒为单位,默认是 120 秒。 + +![](https://assets-docs.dify.ai/2025/03/a0359b706a8e7526c12487dc6d78c983.png) + +当使用工作流时,LangBot 会显式传入以下参数,您可以自行在 Dify 工作流的开始节点中添加: + +- `user_message_text`:用户消息的纯文本 +- `session_id`:用户会话id,私聊为 `person_`,群聊为 `group_` +- `conversation_id`:字符串,用户会话id,由 LangBot 生成。用户重置会话后,会重新生成 +- `msg_create_time`:数字类型,收到此消息的时间戳(秒) + +您可以[通过插件自定义任何变量](https://docs.langbot.app/plugin/dev/api-ref.html#设置请求变量) + +![](https://assets-docs.dify.ai/2025/03/6db041d813987581b27ce434001575bb.png) + +使用 工作流 应用或 Agent 应用时,如果开启了`platform.json`中的`track-function-calls`,将会在 Dify 执行每个工具调用时,输出一个`调用函数xxx`的消息给用户。 +但如果是使用`chat`应用下的`ChatFlow`(聊天助手->工作流编排),无论如何只会输出 Answer(直接回复)节点返回的文本。 + +## 4. 效果展示 + +> 下面仅为微信和飞书的,其他平台如 QQ、钉钉、Telegram 等平台均可接入 + +![](https://assets-docs.dify.ai/2025/03/88bfcb4e72ab852069d49104ad7aa51d.png) + +![](https://assets-docs.dify.ai/2025/03/9682c62f9bcafcffb0b61c2b0f5a6cb1.png) + diff --git a/zh-hans/learn-more/use-cases/dify-on-dingtalk.mdx b/zh-hans/learn-more/use-cases/dify-on-dingtalk.mdx index 8e344edc..98b593b6 100644 --- a/zh-hans/learn-more/use-cases/dify-on-dingtalk.mdx +++ b/zh-hans/learn-more/use-cases/dify-on-dingtalk.mdx @@ -52,7 +52,7 @@ IM 是天然的智能聊天机器人应用场景,校企用户有不少是使 为了让钉钉机器人的回复也实现打字机一样的流式输出效果,需要用到钉钉近来针对 AI 功能开放的 AI 卡片。 -进入钉钉开发者后台,顶部菜单 -> 开放能力 ->[卡片平台](https://open-dev.dingtalk.com/fe/card) -> 新建模版,来新建一个 AI 卡片模板,填入你喜欢的模版名称,卡片类型选择 **消息卡片**,卡片模板场景选择 **AI 卡片**,并 **关联刚才创建的应用**。 +进入钉钉开发者后台,顶部菜单 -> 开放能力 ->[卡片平台](https://open-dev.dingtalk.com/fe/card) -> 新建模板,来新建一个 AI 卡片模板,填入你喜欢的模板名称,卡片类型选择 **消息卡片**,卡片模板场景选择 **AI 卡片**,并 **关联刚才创建的应用**。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/aab6222bfa21484406f07a477b412a4d.jpeg) @@ -60,7 +60,7 @@ IM 是天然的智能聊天机器人应用场景,校企用户有不少是使 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/f9c3c75624e6584f27d078003d31e817.jpeg) -最后点击保存,发布,显示 “模版发布成功”,然后返回到刚才的模版列表页面,复制 \*\* 模版 ID\*\*,保存下来一会儿会用到。 +最后点击保存,发布,显示 “模板发布成功”,然后返回到刚才的模板列表页面,复制 \*\* 模板 ID\*\*,保存下来一会儿会用到。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/25cf3ab088526aa4fb3caf2898ec8c61.jpeg) @@ -99,7 +99,7 @@ DEFAULT_MAX_WORKERS=2 DIFY_OPEN_API_URL="https://api.dify.ai/v1" # 用户各自上下文维持时间,默认 15 minutes,只对 chatbot app 有效 DIFY_CONVERSATION_REMAIN_TIME=15 -# 钉钉 AI 卡片模版 ID,上文 2.3. 步骤里记录的 +# 钉钉 AI 卡片模板 ID,上文 2.3. 步骤里记录的 DINGTALK_AI_CARD_TEMPLATE_ID="" ``` diff --git a/zh-hans/learn-more/use-cases/dify-on-wechat.mdx b/zh-hans/learn-more/use-cases/dify-on-wechat.mdx index ad5cce8a..ea481882 100644 --- a/zh-hans/learn-more/use-cases/dify-on-wechat.mdx +++ b/zh-hans/learn-more/use-cases/dify-on-wechat.mdx @@ -2,39 +2,39 @@ title: 手把手教你把 Dify 接入微信生态 --- -> 作者:韩方圆,"Dify on WeChat"开源项目作者 +> 作者:韩方圆,"Dify on WeChat" 开源项目作者 ## 1. 概述 微信作为最热门的即时通信软件,拥有巨大的流量。 -微信友好的聊天窗口是天然的AI应用LUI(Language User Interface)/CUI(Command User Interface)。 +微信友好的聊天窗口是天然的 AI 应用 LUI (Language User Interface)/CUI (Command User Interface)。 微信不仅有个人微信,同时提供了公众号、企业微信、企业微信应用、企业微信客服等对话渠道,拥有良好的微信生态。 -把Dify应用接入微信生态,就能打造一个功能强大的智能客服,大大降低客服成本,同时也能够提升客户体验。本篇教程就是手把手地教你如何利用[Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat)项目,把Dify应用接入微信生态。 +把 Dify 应用接入微信生态,就能打造一个功能强大的智能客服,大大降低客服成本,同时也能够提升客户体验。本篇教程就是手把手地教你如何利用 [Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat) 项目,把 Dify 应用接入微信生态。 -## 2. Dify接入个人微信 +## 2. Dify 接入个人微信 ### 2.1. 准备工作 #### 2.1.1. 创建聊天助手 -**(1)Dify简介** +**(1)Dify 简介** -Dify是一个优秀的LLMOps(大型语言模型运维)平台,Dify的详细介绍请移步官方文档[欢迎使用 Dify | 中文 | Dify](https://docs.dify.ai/v/zh-hans)。 +Dify 是一个优秀的 LLMOps(大型语言模型运维)平台,Dify 的详细介绍请移步官方文档 [欢迎使用 Dify | 中文 | Dify](https://docs.dify.ai/v/zh-hans)。 -**(2)登录Dify官方应用平台** +**(2)登录 Dify 官方应用平台** -首先,登录[Dify官方应用平台](https://cloud.dify.ai/signin),你可以选择使用Github登录或者使用Google登录。此外,你也可以参考Dify官方教程[Docker Compose 部署 | 中文 | Dify](/zh-hans/getting-started/install-self-hosted/docker-compose) 私有部署,Dify是开源项目,支持私有部署。 +首先,登录 [Dify 官方应用平台](https://cloud.dify.ai/signin),你可以选择使用 Github 登录或者使用 Google 登录。此外,你也可以参考 Dify 官方教程 [Docker Compose 部署 | 中文 | Dify](/zh-hans/getting-started/install-self-hosted/docker-compose) 私有部署,Dify 是开源项目,支持私有部署。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/4d59263223217b94f8c7b4fb8a2951b4.jpeg) -**(3)创建Dify基础编排聊天助手应用** +**(3)创建 Dify 基础编排聊天助手应用** ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/08ece9f6dd15b6ba3c44eb187ea73bdd.jpeg) -登录成功后,进入Dify页面,我们按照下方步骤创建一个基础编排聊天助手应用 +登录成功后,进入 Dify 页面,我们按照下方步骤创建一个基础编排聊天助手应用 1. 点击页面上方的工作室 2. 创建空白应用 @@ -47,7 +47,7 @@ Dify是一个优秀的LLMOps(大型语言模型运维)平台,Dify的详细 创建成功后我们会跳转到上图所示页面,我们继续配置应用 -1. 选择模型,如gpt-3.5-turbo-0125 +1. 选择模型,如 gpt-3.5-turbo-0125 2. 设置模型参数 3. 填写应用提示词 @@ -57,27 +57,27 @@ Dify是一个优秀的LLMOps(大型语言模型运维)平台,Dify的详细 1. 发布 2. 更新 -3. 访问API +3. 访问 API -**(4)生成基础编排聊天助手API密钥** +**(4)生成基础编排聊天助手 API 密钥** ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/de85ada57a6f1a0029486dbdaea62fcf.jpeg) -在点击"访问API"后,我们会跳转到上图的API管理页面,在这个页面我们按照如下步骤获取API密钥: +在点击 "访问 API" 后,我们会跳转到上图的 API 管理页面,在这个页面我们按照如下步骤获取 API 密钥: -1. 点击右上角API密钥 +1. 点击右上角 API 密钥 2. 点击创建密钥 3. 复制保存密钥 -在保存密钥后,还需要查看右上角的API服务器,如果是Dify官网的应用,API服务器地址为 "https://api.dify.ai/v1", 如果是私有部署的,请确认你自己的API服务器地址。 +在保存密钥后,还需要查看右上角的 API 服务器,如果是 Dify 官网的应用,API 服务器地址为 "https://api.dify.ai/v1", 如果是私有部署的,请确认你自己的 API 服务器地址。 -至此,创建聊天助手的准备工作结束,在此小节中我们只需要保存好两个东西:**API密钥**与**API服务器地址** +至此,创建聊天助手的准备工作结束,在此小节中我们只需要保存好两个东西:**API 密钥** 与**API 服务器地址** -#### 2.1.2. 下载Dify on WeChat项目 +#### 2.1.2. 下载 Dify on WeChat 项目 -**(1)Dify on WeChat项目简介** +**(1)Dify on WeChat 项目简介** -[Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat)是[ ChatGPT on WeChat](https://github.com/zhayujie/chatgpt-on-wechat)的下游分支,额外实现了对接[Dify](https://github.com/langgenius/dify) API,支持Dify聊天助手、支持Agent调用工具和知识库,支持Dify工作流,详情请查看GitHub仓库[Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat)。 +[Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat) 是 [ ChatGPT on WeChat](https://github.com/zhayujie/chatgpt-on-wechat) 的下游分支,额外实现了对接 [Dify](https://github.com/langgenius/dify) API,支持 Dify 聊天助手、支持 Agent 调用工具和知识库,支持 Dify 工作流,详情请查看 GitHub 仓库 [Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat)。 **(2)下载代码并安装依赖** @@ -88,9 +88,9 @@ git clone https://github.com/hanfangyuan4396/dify-on-wechat cd dify-on-wechat/ ``` -2. 安装python +2. 安装 python -Dify on WeChat项目使用python语言编写,请在[python官网](https://www.python.org/downloads/)下载安装python,推荐安装python3.8以上版本,我在ubuntu测试过3.11.6版本,可以正常运行。 +Dify on WeChat 项目使用 python 语言编写,请在 [python 官网](https://www.python.org/downloads/) 下载安装 python,推荐安装 python3.8 以上版本,我在 ubuntu 测试过 3.11.6 版本,可以正常运行。 3. 安装核心依赖(必选): @@ -106,9 +106,9 @@ pip3 install -r requirements-optional.txt # 国内可以在该命令末尾添加 **(3)填写配置文件** -我们在项目根目录创建名为config.json的文件,文件内容如下,我们在**2.1.1小节(4)** 最后保存了**API密钥**与**API服务器地址**,请把**dify\_api\_base**配置为**API服务器地址**;**dify\_api\_key**配置为**API密钥**其他配置保持不变。 +我们在项目根目录创建名为 config.json 的文件,文件内容如下,我们在**2.1.1 小节(4)** 最后保存了**API 密钥** 与**API 服务器地址**,请把**dify\_api\_base** 配置为**API 服务器地址**;**dify\_api\_key** 配置为**API 密钥** 其他配置保持不变。 -(PS: 很多朋友可能并不是严格按照我教程给出的步骤创建**聊天助手类型**的Dify应用,在此特别说明一下**dify\_app\_type**配置方法,如果你创建了**聊天助手**应用请配置为**chatbot**;创建了**Agent**应用请配置为**agent** 创建了**工作流**应用请配置为**workflow**。) +(PS: 很多朋友可能并不是严格按照我教程给出的步骤创建**聊天助手类型** 的 Dify 应用,在此特别说明一下**dify_app_type** 配置方法,如果你创建了**聊天助手** 应用请配置为**chatbot**;创建了**Agent** 应用请配置为**agent** 创建了**工作流** 应用请配置为**workflow**。) ```bash { @@ -128,26 +128,26 @@ pip3 install -r requirements-optional.txt # 国内可以在该命令末尾添加 #### 2.2.1. 快速启动测试 -**(1)在Dify on Wechat项目根目录执行如下命令** +**(1)在 Dify on Wechat 项目根目录执行如下命令** ```bash cd dify-on-wechat -python3 app.py # windows环境下该命令通常为 python app.py +python3 app.py # windows 环境下该命令通常为 python app.py ``` **(2)扫码登录** ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/dff732ee33dce1fffa3ea22f4fb7194b.jpeg) -本项目使用itchat实现个人微信登录,有封号风险,建议使用**实名认证**过的**微信小号**进行测试,在执行上述命令后,我们可以在控制台看到打印如上图所示二维码,使用微信扫码登录,登录后当看到"itchat:Start auto replying."字符,表示登录成功,我们可以进行测试。 +本项目使用 itchat 实现个人微信登录,有封号风险,建议使用** 实名认证** 过的** 微信小号** 进行测试,在执行上述命令后,我们可以在控制台看到打印如上图所示二维码,使用微信扫码登录,登录后当看到 "itchat:Start auto replying." 字符,表示登录成功,我们可以进行测试。 **(3)对话测试** ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/634f08492602c77e415c183278b7a3a0.jpeg) -我们看到,微信机器人的回复与在Dify测试页面上的回复一致。至此,恭喜你成功把Dify接入了个人微信🎉🎉🎉 +我们看到,微信机器人的回复与在 Dify 测试页面上的回复一致。至此,恭喜你成功把 Dify 接入了个人微信🎉🎉🎉 -(PS: 有些朋友到这里可能在日志中看到正常回复了消息,但是微信中没有收到消息,请**不要用自己的微信给自己发消息**) +(PS: 有些朋友到这里可能在日志中看到正常回复了消息,但是微信中没有收到消息,请** 不要用自己的微信给自己发消息**) **(4)服务器部署** @@ -158,11 +158,11 @@ cd dify-on-wechat nohup python3 app.py & tail -f nohup.out # 在后台运行程序并通过日志输出二维码 ``` -2. docker compose部署 +2. docker compose 部署 -容器的**环境变量**会**覆盖**config.json文件的配置,请修改docker/docker-compose.yml文件环境变量为你实际的配置,配置方法与**2.1.1小节(4)** 的config.json配置一致。 +容器的**环境变量** 会**覆盖** config.json 文件的配置,请修改 docker/docker-compose.yml 文件环境变量为你实际的配置,配置方法与**2.1.1 小节 (4)** 的 config.json 配置一致。 -请确保正确配置**DIFY\_API\_BASE**, **DIFY\_API\_KEY**与**DIFY\_APP\_TYPE**环境变量。 +请确保正确配置**DIFY\_API\_BASE**,**DIFY\_API\_KEY** 与**DIFY\_APP\_TYPE** 环境变量。 ```yaml version: '2.0' @@ -186,14 +186,14 @@ services: 然后执行如下命令启动容器 ```bash -cd dify-on-wechat/docker # 进入docker目录 -docker compose up -d # 启动docker容器 +cd dify-on-wechat/docker # 进入 docker 目录 +docker compose up -d # 启动 docker 容器 docker logs -f dify-on-wechat # 查看二维码并登录 ``` ### 2.3. 把工作流编排聊天助手接入微信 -在把Dify基础的聊天助手应用接入微信后,我们接下来增加难度,尝试把工作流编排聊天助手应用接入微信,实现一个具有Dify平台知识的微信智能客服,为我们解答Dify工作流相关知识。 +在把 Dify 基础的聊天助手应用接入微信后,我们接下来增加难度,尝试把工作流编排聊天助手应用接入微信,实现一个具有 Dify 平台知识的微信智能客服,为我们解答 Dify 工作流相关知识。 #### 2.3.1. 创建知识库 @@ -201,9 +201,9 @@ docker logs -f dify-on-wechat # 查看二维码并登录 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/aa7354d9fa205665142871199f82ad08.jpeg) -我们到[dify文档仓库](../../guides/workflow/)下载Dify工作流介绍的文档。 +我们到 [dify 文档仓库](../../guides/workflow/) 下载 Dify 工作流介绍的文档。 -**(2)Dify中导入知识库** +**(2)Dify 中导入知识库** ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/e89b108734c4e219ba0a88f2a09e8069.jpeg) @@ -211,7 +211,7 @@ docker logs -f dify-on-wechat # 查看二维码并登录 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/3c1211094029b94c00e1867e12dc0347.jpeg) -选择导入已有文本,上传刚才下载的introduce.md文件,点击下一步 +选择导入已有文本,上传刚才下载的 introduce.md 文件,点击下一步 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/8ed084c50189610e1f0c7c4b92ea45fc.jpeg) @@ -233,35 +233,35 @@ docker logs -f dify-on-wechat # 查看二维码并登录 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/56870383783474ac8edf656cfd0039c8.jpeg) -我们进入Dify工作室,点击从应用模板创建 +我们进入 Dify 工作室,点击从应用模板创建 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/f6bb7d07d20f0dc20ec42878ff83ee91.jpeg) -我们使用知识库+聊天机器人类型的模板,设置应用图标与名称,点击创建 +我们使用知识库 + 聊天机器人类型的模板,设置应用图标与名称,点击创建 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/006cf36de5b5a852cf2ed194ef89a176.jpeg) -跳转到工作流编排页面后,先点击知识检索节点,点击最右侧"+"添加知识库。我们选择之前上传好的introduce.md知识库,该知识库是对Dify工作流的基本介绍。最后我们点击添加,知识库节点设置完成。 +跳转到工作流编排页面后,先点击知识检索节点,点击最右侧 "+" 添加知识库。我们选择之前上传好的 introduce.md 知识库,该知识库是对 Dify 工作流的基本介绍。最后我们点击添加,知识库节点设置完成。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/3687f1b90a3dba06af9d4625579196e8.jpeg) -接下来选择LLM节点,点击设置上下文,我们选择result变量,该变量存有知识检索的结果。 +接下来选择 LLM 节点,点击设置上下文,我们选择 result 变量,该变量存有知识检索的结果。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/4d9d7dafe2007c6205a5da92120de7d6.jpeg) -设置完LLM节点后,我们点击预览进行测试,输入问题:请介绍一下dify工作流。可以看到最终输出了Dify工作流的正确介绍。测试正常后,我们返回编辑模式。 +设置完 LLM 节点后,我们点击预览进行测试,输入问题:请介绍一下 dify 工作流。可以看到最终输出了 Dify 工作流的正确介绍。测试正常后,我们返回编辑模式。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/9e20dccdcbab74679c7a238d4a3db62f.jpeg) -返回编辑模式后,依次点击发布、更新、访问API +返回编辑模式后,依次点击发布、更新、访问 API -#### 2.3.3. 生成工作流编排聊天助手API密钥 +#### 2.3.3. 生成工作流编排聊天助手 API 密钥 -在跳转到API管理页面后,我们参照**2.1.1小节(4)获取"知识库+聊天机器人"应用的API密钥**与**API服务器地址** +在跳转到 API 管理页面后,我们参照**2.1.1 小节 (4) 获取 "知识库 + 聊天机器人" 应用的 API 密钥** 与**API 服务器地址** #### 2.3.4. 接入微信 -与**2.1.2小节(3)类似,我们在项目根目录创建名为config.json的文件,文件内容如下,同样把dify\_api\_base**配置为**知识库+聊天机器人**应用的API服务器地址, **dify\_api\_key**配置为**知识库+聊天机器人**应用的API密钥,其他配置保持不变 +与**2.1.2 小节(3)类似,我们在项目根目录创建名为 config.json 的文件,文件内容如下,同样把 dify\_api\_base** 配置为** 知识库 + 聊天机器人** 应用的 API 服务器地址,**dify\_api\_key** 配置为** 知识库 + 聊天机器人** 应用的 API 密钥,其他配置保持不变 ```bash { @@ -277,43 +277,43 @@ docker logs -f dify-on-wechat # 查看二维码并登录 } ``` -我们按照**2.2.1小节**启动程序并扫码登录,然后给微信机器人发送消息,进行测试 +我们按照**2.2.1 小节** 启动程序并扫码登录,然后给微信机器人发送消息,进行测试 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/1a92cbd66d81e504a72f7cb1f01567a8.jpeg) -微信机器人的回复与在Dify测试页面上的回复一致。恭喜你更进一步,把工作流编排应用接入了个人微信,你可以向知识库中导入更多的Dify官方文档,让微信机器人为你解答更多的Dify相关问题。 +微信机器人的回复与在 Dify 测试页面上的回复一致。恭喜你更进一步,把工作流编排应用接入了个人微信,你可以向知识库中导入更多的 Dify 官方文档,让微信机器人为你解答更多的 Dify 相关问题。 -### 2.4. 把Agent接入微信 +### 2.4. 把 Agent 接入微信 -#### 2.4.1. 创建Agent应用 +#### 2.4.1. 创建 Agent 应用 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/3448bd70c5071882f50667327e35739a.jpeg) -进入工作室页面,点击创建空白应用,选择Agent,设置图标和应用名称,最后点击创建 +进入工作室页面,点击创建空白应用,选择 Agent,设置图标和应用名称,最后点击创建 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/4800cb647f0ff90d5521b859e9403f04.jpeg) -创建成功后,我们会进入Agent应用配置页面,在这个页面我们选择好对话模型,然后添加工具。我们首先添加DALL-E绘画工具,首次使用该工具需要授权,一般我们设置好OpenAI API key和OpenAI base URL即可使用该DALL-E绘画工具。 +创建成功后,我们会进入 Agent 应用配置页面,在这个页面我们选择好对话模型,然后添加工具。我们首先添加 DALL-E 绘画工具,首次使用该工具需要授权,一般我们设置好 OpenAI API key 和 OpenAI base URL 即可使用该 DALL-E 绘画工具。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/bee33065bc070facda8ce81a54d3e3c1.jpeg) -授权成功后,我们添加DALL-E 3绘画工具 +授权成功后,我们添加 DALL-E 3 绘画工具 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/e637c7865118b52f84f619a7637a0347.jpeg) -接着,继续添加DuckDuckGo搜索引擎和数学工具,进行后续的工具测试 +接着,继续添加 DuckDuckGo 搜索引擎和数学工具,进行后续的工具测试 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/32bc3686664423c0f12b5d19c7bf8739.jpeg) -我们输入问题"搜索开源项目Dify的star数量,这个数量乘以3.14是多少",确认应用能够正常调用工具,我们依次点击发布、更新、访问API +我们输入问题 "搜索开源项目 Dify 的 star 数量,这个数量乘以 3.14 是多少",确认应用能够正常调用工具,我们依次点击发布、更新、访问 API -#### 2.4.2. 生成Agent API密钥 +#### 2.4.2. 生成 Agent API 密钥 -我们继续参照**2.1.1小节(4)获取智能助手**应用的**API密钥**与**API服务器地址** +我们继续参照**2.1.1 小节(4)获取智能助手** 应用的**API 密钥** 与**API 服务器地址** #### 2.4.3. 接入微信 -我们在项目根目录创建名为config.json的文件,文件内容如下,同样把**dify\_api\_base**配置为**智能助手**应用的API服务器地址;**dify\_api\_key**配置为**智能助手**应用的API密钥,注意该应用为**智能助手**类型应用,还需要把**dify\_app\_type**设置为**agent**,其他配置保持不变 +我们在项目根目录创建名为 config.json 的文件,文件内容如下,同样把**dify\_api\_base** 配置为** 智能助手** 应用的 API 服务器地址;**dify\_api\_key** 配置为** 智能助手** 应用的 API 密钥,注意该应用为** 智能助手** 类型应用,还需要把**dify\_app\_type** 设置为**agent**,其他配置保持不变 ```bash { @@ -329,11 +329,11 @@ docker logs -f dify-on-wechat # 查看二维码并登录 } ``` -继续参照**2.2.1小节**启动程序并扫码登录,然后给微信机器人发送消息,进行测试 +继续参照**2.2.1 小节** 启动程序并扫码登录,然后给微信机器人发送消息,进行测试 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/8c06ab5d23c2c144b35e82524f7e38d9.jpeg) -可以看到微信机器人可以正常使用搜索和绘画工具。再一次恭喜你,把Dify Agent应用接入微信。也恭喜我,写到这里可以先睡觉了。 +可以看到微信机器人可以正常使用搜索和绘画工具。再一次恭喜你,把 Dify Agent 应用接入微信。也恭喜我,写到这里可以先睡觉了。 ### 2.5. 把工作流接入微信 @@ -341,25 +341,25 @@ docker logs -f dify-on-wechat # 查看二维码并登录 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/1635ba3e6b7417a49a29b42224a0aa29.jpeg) -首先你需要提前下载好我预先创建的DSL文件,[点击此处下载](https://github.com/hanfangyuan4396/dify-on-wechat/blob/master/dsl/chat-workflow.yml)。下载完成后,进入工作室页面,点击导入DSL文件,上传提前下载好的文件,最后点击创建。 +首先你需要提前下载好我预先创建的 DSL 文件,[点击此处下载](https://github.com/hanfangyuan4396/dify-on-wechat/blob/master/dsl/chat-workflow.yml)。下载完成后,进入工作室页面,点击导入 DSL 文件,上传提前下载好的文件,最后点击创建。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/872b3fa4febd26ec20e0657398d2020b.jpeg) 创建完成后,按照上图步骤进行测试。点击运行,输入你好,确保该工作流能正常输出结果。 -你可以在此工作流的基础上进行修改,但是对于**工作流类型**的应用,它的输入变量名称十分灵活,,为了更方便地接入微信机器人,[Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat)项目约定**工作流类型**的应用**输入变量命名为`query`**,**输出变量命名为`text`**。 +你可以在此工作流的基础上进行修改,但是对于** 工作流类型** 的应用,它的输入变量名称十分灵活,,为了更方便地接入微信机器人,[Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat) 项目约定** 工作流类型** 的应用** 输入变量命名为 `query`**,** 输出变量命名为 `text`**。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/56d2e2a1b4aac390055fb2d3e49eaf4c.jpeg) -测试没有问题后,按照上图步骤发布应用,依次点击发布、更新、访问API。 +测试没有问题后,按照上图步骤发布应用,依次点击发布、更新、访问 API。 -#### 2.5.2. 生成工作流API密钥 +#### 2.5.2. 生成工作流 API 密钥 -我们同样参照**2.1.1小节(4)获取工作流**应用的**API密钥**与**API服务器地址**。 +我们同样参照**2.1.1 小节(4)获取工作流** 应用的**API 密钥** 与**API 服务器地址**。 #### 2.5.3. 接入微信 -我们在项目根目录创建名为config.json的文件,文件内容如下,同样把**dify\_api\_base**配置为**工作流**应用的API服务器地址;**dify\_api\_key**配置为**工作流**应用的API密钥,注意该应用为**工作流**类型应用,还需要把**dify\_app\_type**设置为**workflow**,其他配置保持不变 +我们在项目根目录创建名为 config.json 的文件,文件内容如下,同样把**dify\_api\_base** 配置为** 工作流** 应用的 API 服务器地址;**dify\_api\_key** 配置为** 工作流** 应用的 API 密钥,注意该应用为** 工作流** 类型应用,还需要把**dify\_app\_type** 设置为**workflow**,其他配置保持不变 ```bash { @@ -376,42 +376,70 @@ docker logs -f dify-on-wechat # 查看二维码并登录 ``` -同样参照**2.2.1小节**启动程序并扫码登录,然后给微信机器人发送消息,进行测试。 +同样参照**2.2.1 小节** 启动程序并扫码登录,然后给微信机器人发送消息,进行测试。 ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/c4f3c4494aa25bad1877c0dd72995b5f.jpeg) -可以看到机器人成功接通了工作流api并进行了回复,至此我们已经完全掌握了如何创建Dify所有类型的应用:基础聊天助手、工作流聊天助手、智能助手、工作流,我们也学会了如何把上述应用发布为API,并接入微信。 +可以看到机器人成功接通了工作流 api 并进行了回复,至此我们已经完全掌握了如何创建 Dify 所有类型的应用:基础聊天助手、工作流聊天助手、智能助手、工作流,我们也学会了如何把上述应用发布为 API,并接入微信。 接下来我将会介绍如何把应用接入到微信的其他通道,如公众号、企业微信应用、企业微信客服等。 -## 3. Dify接入企业微信个人号(仅限windows环境) +## 3. Dify 接入企业微信个人号(仅限 Windows 环境) -> 1. 有**封号风险**,请使用企业微信**小号**测试 -> 2. 在登录旧版本的企业微信时可能会出现企业微信版本过低,无法登录情况,参考[issue1525](https://github.com/zhayujie/chatgpt-on-wechat/issues/1525),请尝试更换其他企业微信号重试 +> 1. 有**封号风险**,请使用企业微信**小号** 测试 +> 2. 在登录旧版本的企业微信时可能会出现企业微信版本过低,无法登录情况,参考 [issue1525](https://github.com/zhayujie/chatgpt-on-wechat/issues/1525),请尝试更换其他企业微信号重试 ### 3.1. 下载安装企业微信 -确保你有一台windows系统的电脑,然后在此电脑下载安装特定版本的企业微信,[官方下载链接](https://dldir1.qq.com/wework/work\_weixin/WeCom\_4.0.8.6027.exe),[备用下载链接](https://www.alipan.com/s/UxQHrZ5WoxS)。 +确保你有一台 windows 系统的电脑,然后在此电脑下载安装特定版本的企业微信,[官方下载链接](https://dldir1.qq.com/wework/work\_weixin/WeCom\_4.0.8.6027.exe),[备用下载链接](https://www.alipan.com/s/UxQHrZ5WoxS)。 -### 3.2. 创建Dify应用 +笔者目前企业微信最新版本为 4.1.33.6009。即使电脑端下载了旧版本的,然后用手机扫码登录,也会被提示版本过低需要升级 pc 端版本,且无法避免,ntwork-whl 只兼容了固定版本企业微信客户端,最新版本没有兼容。 +解决方案如下: -我们已经在前面的**2.1.1**、**2.3.2**、**2.4.1**与**2.5.1**小节分别介绍了创建基础聊天助手、工作流聊天助手、智能助手、工作流这4种不同的Dify应用,你可以根据上面的教程任意创建一种应用。 +1. 下载并安装最新版本和 4.0.8.6027 版本的企业微信。 -### 3.3. 下载安装Dify on WeChat +![](https://assets-docs.dify.ai/2025/04/306b3158a547de46a05ed53942f10f4a.png) -根据 **2.1.2(2)** 步骤,下载代码并安装依赖,为了后续能按照ntwork依赖,**请确保你安装的python版本为3.8、3.9或3.10**。 +● wxwork_last 文件夹为最新版本的企业微信 +● WxWork 文件夹为 4.0.8.6027 版本 -### 3.4. 安装ntwork依赖 +2. 先打开最新版本的企业微信,并扫码登录。 -由于ntwork的安装源不是很稳定,可以下载对应的whl文件,使用whl文件离线安装ntwork +![](https://assets-docs.dify.ai/2025/04/6e0ee777cd68c094c22739612cf2fbfa.png) -首先需要查看你的python版本,在命令行中输入python查看版本信息,然后在[ntwork-whl](https://github.com/hanfangyuan4396/ntwork-bin-backup/tree/main/ntwork-whl)目录下找到对应的whl文件,运行`pip install xx.whl`安装ntwork依赖,注意"xx.whl"更换为whl文件的**实际路径**。 +打开 Wxwork_last/wxwork.exe 文件,运行最新版本的企业微信,扫码登录。 -例如我的python版本信息为 +3. 登录成功后,打开设置,勾选上启动企业微信后自动登录,去掉自动更新的选项。然后关闭最新版本的企业微信程序 + +![](https://assets-docs.dify.ai/2025/04/a3cf375ad44138e84ac682a6683dd1b6.png) + +![](https://assets-docs.dify.ai/2025/04/adde9f83465492c24b6891482893faec.png) + +4. 现在再打开旧版本的企业微信,即可直接登录。 + +![](https://assets-docs.dify.ai/2025/04/32a45ad18fbb4de03e99753f19cb9d64.png) + +运行 wxwork/wxwork.exe 即可。 + +### 3.2. 创建 Dify 应用 + +我们已经在前面的**2.1.1**、**2.3.2**、**2.4.1** 与**2.5.1** 小节分别介绍了创建基础聊天助手、工作流聊天助手、智能助手、工作流这 4 种不同的 Dify 应用,你可以根据上面的教程任意创建一种应用。 + +### 3.3. 下载安装 Dify on WeChat + +根据**2.1.2 (2)** 步骤,下载代码并安装依赖,为了后续能按照 ntwork 依赖,** 请确保你安装的 python 版本为 3.8、3.9 或 3.10**。 + +### 3.4. 安装 ntwork 依赖 + +由于 ntwork 的安装源不是很稳定,可以下载对应的 whl 文件,使用 whl 文件离线安装 ntwork + +首先需要查看你的 python 版本,在命令行中输入 python 查看版本信息,然后在 [ntwork-whl](https://github.com/hanfangyuan4396/ntwork-bin-backup/tree/main/ntwork-whl) 目录下找到对应的 whl 文件,运行 `pip install xx.whl` 安装 ntwork 依赖,注意 "xx.whl" 更换为 whl 文件的**实际路径**。 + +例如我的 python 版本信息为 "Python 3.8.5 (default, Sep 3 2020, 21:29:08) \[MSC v.1916 64 bit (AMD64)]" -可以看到python版本是**3.8.5**,并且是**AMD64**,所以对应的whl文件为**ntwork-0.1.3-cp38-cp38-win\_amd64.whl**,需要执行如下命令安装 +可以看到 python 版本是**3.8.5**,并且是**AMD64**,所以对应的 whl 文件为**ntwork-0.1.3-cp38-cp38-win\_amd64.whl**,需要执行如下命令安装 ```sh pip install your-path/ntwork-0.1.3-cp38-cp38-win_amd64.whl @@ -419,7 +447,7 @@ pip install your-path/ntwork-0.1.3-cp38-cp38-win_amd64.whl ### 3.5. 填写配置文件 -我们在Dify on WeChat项目根目录创建名为config.json的文件,下面是以Dify智能助手应用作为示例的配置文件,请正确填写你刚刚创建应用的dify\_api\_base、dify\_api\_key、dify\_app\_type信息,请注意channel\_type填写为 **wework** +我们在 Dify on WeChat 项目根目录创建名为 config.json 的文件,下面是以 Dify 智能助手应用作为示例的配置文件,请正确填写你刚刚创建应用的 dify\_api\_base、dify\_api\_key、dify\_app\_type 信息,请注意 channel\_type 填写为**wework** ```json { @@ -448,13 +476,13 @@ cd dify-on-wechat python app.py ``` -我们可以看到终端输出如下信息,**等待wework程序初始化完成**,最后启动成功\~ +我们可以看到终端输出如下信息,**等待 wework 程序初始化完成**,最后启动成功 \~ ```bash -[INFO][2024-04-30 21:16:04][wework_channel.py:185] - 等待登录······ +[INFO][2024-04-30 21:16:04][wework_channel.py:185] - 等待登录・・・・・・ [INFO][2024-04-30 21:16:05][wework_channel.py:190] - 登录信息:>>>user_id:xxx>>>>>>>>name: -[INFO][2024-04-30 21:16:05][wework_channel.py:191] - 静默延迟60s,等待客户端刷新数据,请勿进行任何操作······ -[INFO][2024-04-30 21:17:05][wework_channel.py:224] - wework程序初始化完成········ +[INFO][2024-04-30 21:16:05][wework_channel.py:191] - 静默延迟 60s,等待客户端刷新数据,请勿进行任何操作・・・・・・ +[INFO][2024-04-30 21:17:05][wework_channel.py:224] - wework 程序初始化完成・・・・・・・・ ``` ![](https://assets-docs.dify.ai/dify-enterprise-mintlify/zh_CN/learn-more/use-cases/d440a63e5e00845b1854410d63b31bdd.jpeg) @@ -463,4 +491,4 @@ python app.py ## 7. 后记 -我是社畜打工人,精力实在有限,只能晚上下班还有周末空闲时间维护[Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat)项目,单靠我个人开发项目进度十分缓慢,希望大家能一起参与进来这个项目,多多提PR,让Dify的生态变得更好\~ +我是社畜打工人,精力实在有限,只能晚上下班还有周末空闲时间维护 [Dify on WeChat](https://github.com/hanfangyuan4396/dify-on-wechat) 项目,单靠我个人开发项目进度十分缓慢,希望大家能一起参与进来这个项目,多多提 PR,让 Dify 的生态变得更好 \~ diff --git a/zh-hans/plugins/best-practice/how-to-use-mcp-zapier.mdx b/zh-hans/plugins/best-practice/how-to-use-mcp-zapier.mdx new file mode 100644 index 00000000..383af90f --- /dev/null +++ b/zh-hans/plugins/best-practice/how-to-use-mcp-zapier.mdx @@ -0,0 +1,129 @@ +--- +title: Dify MCP 插件指南:一键连接 Zapier 并自动发送邮件 +--- + +**本文将帮助你:** + +为 Dify 工作空间安装 MCP SSE 插件,远程调用 Zapier MCP 服务以实现自动发送邮件。 + +## 项目背景 + +Anthropic 于 2024 年底推出了模型上下文协议(MCP)。作为一项新兴的开放协议,MCP 为 LLM 与外部应用之间构建了双向通信通道,就像是 AI 的“USB-C”接口,帮助模型发现、理解并安全调用各种外部工具或 API。 + +这意味着:开发者不再需要为对接每一个外部服务而编写复杂的定制接口。用户可以体验到 AI 轻松调用海量第三方应用的能力,无论是处理日常办公任务、分析数据,还是执行营销自动化,AI 正从“智能对话”迈向“高效行动”。 + +在 Dify 社区里,MCP 同样备受关注。社区开发者在插件市场贡献了多个 MCP 插件,你可以轻松地通过插件将外部 MCP 服务接入至 Dify Agent 应用或工作流中。 + +本文将以 MCP SSE 插件为例,详细介绍如何在 Dify 内使用 MCP 插件连接 Zapier 并完成自动邮件发送流程。 + +## 前置准备 + +- Dify 云端版 / Dify 社区版 ≥ v1.0.0 +- Zapier 账号 + +## 在 Dify 中初始化 Zapier MCP 服务 + +Zapier 的 MCP Server 将其已有的 7000+ 应用和 30,000+ 操作(Action)统一封装到了一个 MCP Server URL 中。你可以在 Zapier 后台,自主选择和配置需要的工具及操作,比如发邮件、在 CRM 中创建记录、在 Slack 中发送通知等。只需将 MCP Server URL 填入 Dify MCP 插件的配置,就能让 LLM 在对话或流程中,自动调用这些工具完成各类任务。 + +### 步骤一:申请 Zapier MCP Server URL + +1. 访问 [Zapier MCP 设置页面](https://actions.zapier.com/settings/mcp/)。 +2. 获取 MCP Server URL,稍后填写至 Dify 的插件配置。 + +![](https://assets-docs.dify.ai/2025/04/15bba178b0adddcd3e1961807dfe14f0.png) + +3. 点击 URL 下方的 “Edit MCP Actions”,进入工具和操作的添加页面。 + +4. 点击 “Add a new action”,搜索 `Gmail: Send Email`。你也可以根据实际需求选择添加不同的邮件操作。 + +![](https://assets-docs.dify.ai/2025/04/718e214166ca6eed6771d44f3b6ab718.png) + +5. 以“发送邮件”为例: + +在 Gmail 账户下方点击 “Connect”,然后登录并授权你的 Gmail 邮箱。 + +对于邮件的收件人 (To)、主题 (Subject) 和正文 (Body) 等字段,可以选择 “Have AI guess a value for this field” ,具体内容将由 Agent 根据实际对话和场景动态决定。 + +![](https://assets-docs.dify.ai/2025/04/637ce6b46ab706f4512a2dceb25a8162.png) + +6. 设置完成后,你还可以继续添加不同的 Action,丰富 Agent 可用的工具集。 + +### 步骤二:安装 MCP SSE 插件 + +1. 前往 Dify 插件市场,搜索 MCP SSE 插件并点击安装。 + +![](https://assets-docs.dify.ai/2025/04/20174032b8feb624a52ac36d65e7c0fa.png) + +> 为确保服务稳定,建议使用 v0.0.4 插件版本;你可以在工作空间内的插件详情页调整版本。 +> ![](https://assets-docs.dify.ai/2025/04/b076d40ea120dea544df49bc52199ad6.png) + + +2. 点击插件页的 To Authorize 按钮,将上文中获取的 Zapier MCP Server URL 粘贴至插件内。地址格式参考: + +```json +{ + "server_name": { + "url": "https://actions.zapier.com/mcp/*******/sse", + "headers": {}, + "timeout": 5, + "sse_read_timeout": 300 + } +} +``` + +![](https://assets-docs.dify.ai/2025/04/5ba078e8804c1bee5bcec167d260a92a.png) + +### 步骤三:创建 Dify Agent 应用并启用 MCP SSE 服务 + +1. 创建 Agent 类型应用 + +从导航选择 「工作室」,在应用列表内选择 「从空白创建」 并选择 Agent 应用类型,填写应用名称后完成创建。 + +![](https://assets-docs.dify.ai/2025/04/aaef5e115211c2b04382552e537877fa.png) + +2. 添加 MCP 工具 + +在应用工具栏中分别添加 `Fetch MCP Tools` 和 `Call MCP Tool`。 + +![](https://assets-docs.dify.ai/2025/04/4e570e4e42720b3e202d409fa93f983a.png) + +3. 配置 LLM + +使用 MCP 时可能会消耗大量 Tokens,因此建议使用更具性价比的 LLM。本文将以 `deepseek-chat` 模型为例。你可以前往 [DeepSeek Platform](https://platform.deepseek.com/usage) 申请 API Key 并将其填写至 「设置」 → 「模型供应商」 → 「DeepSeek」内。 + +> 若你并未在模型供应商内检索到 DeepSeek 模型,请前往 Dify 插件市场安装 DeepSeek 插件。 + +## 使用场景一:使用 MCP 服务自动发送单条邮件 + +配置完成后,只需通过与 Agent 对话,即可自动生成邮件草稿,并发送给指定收件人。 + +![](https://assets-docs.dify.ai/2025/04/fc76cc8e7dd7476199e9810fa5403f3b.png) + +在对话框内要求 LLM 完成邮件发送任务。等待 MCP 运行完成后,邮件将自动发送至收件人。 + +![](https://assets-docs.dify.ai/2025/04/dc80a8fb00800e8938f3918fc908bc1b.png) + +## 使用场景二:在 Workflow 中配置 MCP Agent Strategy + +除了将 MCP SSE 插件作为工具添加到 Agent 外,你还可以在 Workflow 中使用 MCP Agent Strategy 插件。安装完成后,在对应的 Agent 节点内进行配置,具体操作如下: + +![](https://assets-docs.dify.ai/2025/04/0a340d4cc4a549e6b7420b39cfd805d6.png) + +将以下 JSON 结构作为模板,其中 `url` 值替换为 MCP Server 地址,然后将修改后的完整 JSON,复制粘贴到 `MCP SERVER URL` 配置框内: + +```json +{ + "server_name": { + "url": "https://actions.zapier.com/mcp/*******/sse", + "headers": {}, + "timeout": 5, + "sse_read_timeout": 300 + } +} +``` + +![](https://assets-docs.dify.ai/2025/04/883c70b8a714c0c7e7a25f5f712c59e0.png) + +配置完成后,当 Workflow 运行到该 Agent 节点时,就能够根据 Prompt 指令,利用配置好的 Zapier MCP Server 来执行任务。如下图所示,调用 Gmail 发送邮件: + +![](https://assets-docs.dify.ai/2025/04/a201fb50200737881e4ddc0b31518336.png) diff --git a/zh-hans/plugins/publish-plugins/README.mdx b/zh-hans/plugins/publish-plugins/README.mdx index d7856da2..d6a667a8 100644 --- a/zh-hans/plugins/publish-plugins/README.mdx +++ b/zh-hans/plugins/publish-plugins/README.mdx @@ -74,3 +74,5 @@ title: 发布插件 * **想要推广插件** → **推荐使用 Marketplace**,通过官方审核保障插件质量,提升曝光度。 * **开源共享项目** → **推荐使用 GitHub**,方便版本管理与社区协作。 * **快速分发或内部测试** → **推荐使用插件文件**,简单高效地安装和分享。 + +> 安装非 Dify 市场内的插件时,有可能遇到第三方签名验证问题。解决办法请参考[第三方签名验证](./signing-plugins-for-third-party-signature-verification.mdx)。 diff --git a/zh-hans/plugins/publish-plugins/package-plugin-file-and-publish.mdx b/zh-hans/plugins/publish-plugins/package-plugin-file-and-publish.mdx index 4b5ed219..3d082a02 100644 --- a/zh-hans/plugins/publish-plugins/package-plugin-file-and-publish.mdx +++ b/zh-hans/plugins/publish-plugins/package-plugin-file-and-publish.mdx @@ -2,7 +2,6 @@ title: 打包为本地文件与分享 --- - 完成插件开发后,你可以将插件项目打包为一个本地文件并分享给他人,通过插件文件后即可安装至 Dify Workspace 内。 * **特点**: diff --git a/zh-hans/plugins/publish-plugins/plugin-auto-publish-pr.mdx b/zh-hans/plugins/publish-plugins/plugin-auto-publish-pr.mdx new file mode 100644 index 00000000..562673a8 --- /dev/null +++ b/zh-hans/plugins/publish-plugins/plugin-auto-publish-pr.mdx @@ -0,0 +1,297 @@ +--- +title: 自动发布插件 +--- + +### 背景 + +当插件贡献者需要严肃更新 **已被其他用户使用的 Dify 插件** 时,流程通常非常繁琐:贡献者需要先修改插件源码并更新版本号,将更改推送到插件源码仓库,并在 fork 的 dify-plugin 仓库中创建新分支。随后,贡献者需要手动打包插件并上传打包文件,再创建 PR 合并到原始 dify-plugin 仓库。这个过程必须在每次插件代码变更时重复,非常耗时低效。 + +为了简化这一流程,我们构建了基于 GitHub Actions 的自动化工作流 **Plugin Auto-PR**。借助这个工具,插件贡献者可以一键完成插件打包、分支推送以及 PR 创建。 + +### 概念简介 + +#### GitHub Actions + +GitHub Actions 是 GitHub 提供的内置 CI/CD 服务,可以自动化各种构建、测试和部署任务。 + +**运行原理**:当触发条件(如 push 代码)满足时,GitHub 会自动分配虚拟机运行你的工作流。所有操作都在 GitHub 云端完成。 + +![Workflow](https://assets-docs.dify.ai/2025/04/60534de8e220f860947b32a8329a8349.png) + +**免费额度**: + +* 公共仓库:无限制 +* 私有仓库:每月 2000 分钟 + +#### Plugin Auto-PR + +**运行原理**: + +1. 当你推送代码到插件源码仓库的 main 分支时,触发工作流 +2. 工作流从 `manifest.yaml` 文件中读取插件信息 +3. 自动打包插件为 `.difypkg` 文件 +4. 将打包文件推送到你 fork 的 `dify-plugins` 仓库中 +5. 创建新分支并提交更改 +6. 自动创建 PR 请求合并到上游仓库 + +### 环境准备 + +#### 仓库要求 + +* 你已拥有自己的插件源码仓库(例如:`your-name/plugin-source`) +* 你已拥有自己的 fork 插件仓库(例如:`your-name/dify-plugins`) +* 你的 fork 仓库中已有插件目录结构: + +``` +dify-plugins/ +└── your-author-name + └── plugin-name +``` + +#### 权限要求 + +此工作流需要适当的权限才能正常运行: + +* 你需要创建一个有足够权限的 GitHub Personal Access Token (PAT) +* 该 PAT 必须有权向你的 fork 仓库推送代码 +* 该 PAT 必须有权向上游仓库创建 PR + +### 参数与配置项说明 + +#### 必要参数 + +插件自动发布工作流需要你正确配置以下关键元素: + +**manifest.yaml 文件**:这是整个自动化流程的核心配置源。你需要确保以下字段正确无误: + +* `name`:插件名称(将用于生成包名和分支名) +* `version`:版本号(每次更新时需要递增) +* `author`:GitHub 用户名(用于确定目标仓库路径) + +**PLUGIN_ACTION Secret**:你需要在插件源码仓库中正确设置此密钥。 + +* 值要求:必须是具有足够权限的个人访问令牌(PAT) +* 权限要求:能够推送分支到你的 fork 仓库,能够创建 PR 到上游仓库 + +#### 自动生成的参数 + +工作流会**自动处理以下内容**,无需手动干预: + +* GitHub 用户名:从 `manifest.yaml` 的 `author` 字段读取 +* 作者文件夹名称:与 `author` 字段保持一致 +* 插件名称:从 `manifest.yaml` 的 `name` 字段读取 +* 分支名称:`bump-{插件名}-plugin-{版本号}` +* 打包文件名:`{插件名}-{版本号}.difypkg` +* PR 标题和内容:基于插件名称和版本自动生成 + +### 安装配置步骤 + + + + 确保你已经 fork 了官方的 `dify-plugins` 仓库,并且有自己的插件源码仓库。 + + + 导航到你的插件源码仓库,点击 **Settings > Secrets and variables > Actions > New repository secret**,创建 GitHub Secret: + + * 名称填写: `PLUGIN_ACTION` + * 值填写: 拥有目标仓库(`your-name/dify-plugins`)写入权限的 GitHub Personal Access Token (PAT) + + Create Secrets + + + 在仓库中创建 `.github/workflows/`目录,并在此目录中创建名为 `plugin-publish.yml` 的文件,再将以下内容复制到该文件中: + + ```yaml + # .github/workflows/auto-pr.yml + name: Auto Create PR on Main Push + + on: + push: + branches: [ main ] # Trigger on push to main + + jobs: + create_pr: # Renamed job for clarity + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Print working directory # Kept for debugging + run: | + pwd + ls -la + + - name: Download CLI tool + run: | + # Create bin directory in runner temp + mkdir -p $RUNNER_TEMP/bin + cd $RUNNER_TEMP/bin + + # Download CLI tool + wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.0.6/dify-plugin-linux-amd64 + chmod +x dify-plugin-linux-amd64 + + # Show download location and file + echo "CLI tool location:" + pwd + ls -la dify-plugin-linux-amd64 + + - name: Get basic info from manifest # Changed step name and content + id: get_basic_info + run: | + PLUGIN_NAME=$(grep "^name:" manifest.yaml | cut -d' ' -f2) + echo "Plugin name: $PLUGIN_NAME" + echo "plugin_name=$PLUGIN_NAME" >> $GITHUB_OUTPUT + + VERSION=$(grep "^version:" manifest.yaml | cut -d' ' -f2) + echo "Plugin version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + # If the author's name is not your github username, you can change the author here + AUTHOR=$(grep "^author:" manifest.yaml | cut -d' ' -f2) + echo "Plugin author: $AUTHOR" + echo "author=$AUTHOR" >> $GITHUB_OUTPUT + + - name: Package Plugin + id: package + run: | + # Use the downloaded CLI tool to package + cd $GITHUB_WORKSPACE + # Use variables for package name + PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg" + # Use CLI from runner temp + $RUNNER_TEMP/bin/dify-plugin-linux-amd64 plugin package . -o "$PACKAGE_NAME" + + # Show packaging result + echo "Package result:" + ls -la "$PACKAGE_NAME" + echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT + + # Show full file path and directory structure (kept for debugging) + echo "\\nFull file path:" + pwd + echo "\\nDirectory structure:" + tree || ls -R + + - name: Checkout target repo + uses: actions/checkout@v3 + with: + # Use author variable for repository + repository: ${{steps.get_basic_info.outputs.author}}/dify-plugins + path: dify-plugins + token: ${{ secrets.PLUGIN_ACTION }} + fetch-depth: 1 # Fetch only the last commit to speed up checkout + persist-credentials: true # Persist credentials for subsequent git operations + + - name: Prepare and create PR + run: | + # Debug info (kept) + echo "Debug: Current directory $(pwd)" + # Use variable for package name + PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg" + echo "Debug: Package name: $PACKAGE_NAME" + ls -la + + # Move the packaged file to the target directory using variables + mkdir -p dify-plugins/${{ steps.get_basic_info.outputs.author }}/${{ steps.get_basic_info.outputs.plugin_name }} + mv "$PACKAGE_NAME" dify-plugins/${{ steps.get_basic_info.outputs.author }}/${{ steps.get_basic_info.outputs.plugin_name }}/ + + # Enter the target repository directory + cd dify-plugins + + # Configure git + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + + # Ensure we are on the latest main branch + git fetch origin main + git checkout main + git pull origin main + + # Create and switch to a new branch using variables and new naming convention + BRANCH_NAME="bump-${{ steps.get_basic_info.outputs.plugin_name }}-plugin-${{ steps.get_basic_info.outputs.version }}" + git checkout -b "$BRANCH_NAME" + + # Add and commit changes (using git add .) + git add . + git status # for debugging + # Use variables in commit message + git commit -m "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin to version ${{ steps.get_basic_info.outputs.version }}" + + # Push to remote (use force just in case the branch existed before from a failed run) + git push -u origin "$BRANCH_NAME" --force + + # Confirm branch has been pushed and wait for sync (GitHub API might need a moment) + git branch -a + echo "Waiting for branch to sync..." + sleep 10 # Wait 10 seconds for branch sync + + - name: Create PR via GitHub API + env: + GH_TOKEN: ${{ secrets.PLUGIN_ACTION }} # Use the provided token for authentication + run: | + gh pr create \ + --repo langgenius/dify-plugins \ + --head "${{ steps.get_basic_info.outputs.author }}:${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}" \ + --base main \ + --title "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin to version ${{ steps.get_basic_info.outputs.version }}" \ + --body "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin package to version ${{ steps.get_basic_info.outputs.version }} + + Changes: + - Updated plugin package file" || echo "PR already exists or creation skipped." # Handle cases where PR already exists + + - name: Print environment info # Kept for debugging + run: | + echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE" + echo "Current directory contents:" + ls -R + ``` + + + 确保 `manifest.yaml` 文件正确设置以下字段: + + ```yaml + version: 0.0.x # Version number + author: your-github-username # GitHub username/Author name + name: your-plugin-name # Plugin name + ``` + + + +### 使用指南 + +#### 初次使用流程 + +首次设置自动发布工作流时,需要完成以下步骤: + +1. 确保你已经 fork 了官方的 `dify-plugins` 仓库 +2. 确保你的插件源码仓库结构正确 +3. 在插件源码仓库中设置 `PLUGIN_ACTION Secret` +4. 创建工作流文件 `.github/workflows/plugin-publish.yml` +5. 确保 `manifest.yaml` 文件中的 `name` 和 `author` 字段正确配置 + +#### 后续更新流程 + +设置完成后,每次需要发布新版本时,只需: + +1. 修改插件代码 +2. 更新 `manifest.yaml` 中的 `version` 字段 + +![Release](https://assets-docs.dify.ai/2025/04/9eed2b9110e91e18008b399e58198f03.png) + +3. 将所有更改推送到 main 分支 +4. 等待 GitHub Actions 自动完成打包、分支创建和 PR 提交 + +### 执行效果展示 + +当你推送代码到插件源码仓库的 main 分支时,GitHub Actions 将自动执行发布流程: + +* 自动打包插件为 `{plugin-name}-{version}.difypkg` 格式 +* 自动将打包文件推送到目标仓库 +* 自动创建 PR 合并到 fork 仓库 + +![Outcome](https://assets-docs.dify.ai/2025/04/60d5de910c6ce2482c67ddec3320311f.png) + +### 示例仓库 + +你可以参考[示例仓库](https://github.com/Yevanchen/exa-in-dify),了解完整的配置细节和最佳实践。 diff --git a/zh-hans/plugins/publish-plugins/publish-plugin-on-personal-github-repo.mdx.bak b/zh-hans/plugins/publish-plugins/publish-plugin-on-personal-github-repo.mdx.bak deleted file mode 100644 index 3e30b664..00000000 --- a/zh-hans/plugins/publish-plugins/publish-plugin-on-personal-github-repo.mdx.bak +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: 发布至个人 GitHub 仓库 ---- - - -支持通过 GitHub 仓库链接安装插件。插件开发完成后,你可以选择将插件发布至公开 GitHub 仓库供其他人下载和使用。该方式具备以下优势: - -• **个人管理**:你可以完全控制插件的代码和更新 - -• **快速分享**:通过 GitHub 链接即可轻松分享给其他用户或团队成员,便于测试和使用 - -• **协作与反馈**:将插件开源后,有可能会吸引 GitHub 上潜在的协作者,帮助您快速改进插件 - -本文将指导你如何将插件发布到 GitHub 仓库。 - -### 准备工作 - -* GitHub 账号 -* 创建一个新的公开 GitHub 仓库 -* 本地已安装 Git 工具 - -关于 GitHub 的基础知识,请参考 [GitHub 文档](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-new-repository)。 - -### 1. 完善插件项目 - -将上传至公开的 GitHub 意味着你将公开插件。请确保你已完成插件的调试和验证,并已完善插件的 `README.md` 文件说明。 - -建议说明文件包含以下内容: - -* 插件的简介和功能描述 -* 安装和配置步骤 -* 使用示例 -* 联系方式或贡献指南 - -### 2. 初始化本地插件仓库 - -将插件公开上传至 GitHub 之前,请确保已完成插件的调试和验证工作。在终端中导航到插件项目文件夹,并运行以下命令: - -```bash -git init -git add . -git commit -m "Initial commit: Add plugin files" -``` - -如果你是第一次使用 Git,可能还需要配置 Git 用户名和邮箱: - -```bash -git config --global user.name "Your Name" -git config --global user.email "your.email@example.com" -``` - -### 3. 连接远程仓库 - -使用以下命令,将本地仓库连接到 GitHub 仓库: - -```bash -git remote add origin https://github.com//.git -``` - -### 4. 上传插件文件 - -> 打包插件前,请确保插件的 `manifest.yaml` 文件和 `/provider` 路径下的 `.yaml` 文件中的 author 字段与 GitHub ID 保持一致。 - -将插件项目推送到 GitHub 仓库: - -```bash -git branch -M main -git push -u origin main -``` - -上传代码时建议附上标签,以便后续打包代码。 - -```bash -git tag -a v0.0.1 -m "Release version 0.0.1" - -git push origin v0.0.1 -``` - -### 5. 打包插件代码 - -前往 GitHub 代码仓库的 Releases 页,创建一个新的版本发布。发布版本时需上传插件文件。关于如何打包插件文件,详细说明请阅读[打包插件](broken-reference)。 - -![打包插件](https://assets-docs.dify.ai/2024/12/5cb4696348cc6903e380287fce8f529d.png) - -### 通过 GitHub 安装插件 - -其他人可以通过 GitHub 仓库地址安装该插件。访问 Dify 平台的插件管理页,选择通过 GitHub 安装插件,输入仓库地址后,选择版本号和包文件完成安装。 - -![](https://assets-docs.dify.ai/2024/12/3c2612349c67e6898a1f33a7cc320468.png) - - - diff --git a/zh-hans/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification.mdx b/zh-hans/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification.mdx new file mode 100644 index 00000000..d7696089 --- /dev/null +++ b/zh-hans/plugins/publish-plugins/signing-plugins-for-third-party-signature-verification.mdx @@ -0,0 +1,100 @@ +--- +title: 第三方签名验证 +--- + + +此功能仅在 Dify 社区版中可用,Dify 云端版目前不支持第三方签名验证。 + + +第三方签名验证允许 Dify 管理员安全地安装尚未在 Dify 市场上提供的插件,而无需修改 `.env` 文件绕开签名验证安全限制。 + +**使用场景:** + +* 一经同意,Dfy 管理员可以为插件添加由开发者发送的签名。 +* 插件开发者可以为他们的插件添加签名,并将其与公钥一起发布给无法禁用签名验证的 Dify 管理员。 + +Dify 管理员和插件开发者都可以使用预先生成的密钥对为插件添加签名。此外,管理员可以配置 Dify 在插件安装过程中使用特定公钥强制执行签名验证。 + +## 生成用于签名和验证的密钥对 + +使用以下命令生成新的密钥对,用于添加和验证插件签名: + +```bash +dify signature generate -f your_key_pair +``` + +运行此命令后,将在当前目录中生成两个文件: + +* **私钥**:`your_key_pair.private.pem` +* **公钥**:`your_key_pair.public.pem` + +私钥用于签名插件,公钥用于验证插件的签名。 + +请妥善保管私钥。如果私钥被泄露,攻击者可以为任何插件添加有效签名,这将危及 Dify 社区版的安全性。 + +## 为插件添加签名并验证 + +运行以下命令为插件添加签名。请注意,你需要指定**待签名的插件文件**和**私钥**: + +```bash +dify signature sign your_plugin_project.difypkg -p your_key_pair.private.pem +``` + +执行命令后,将在同一目录中生成一个新的插件文件,文件名中添加了 `signed`:`your_plugin_project.signed.difypkg` + +你可以使用以下命令验证插件是否已正确签名。运行命令时需要指定**已签名的插件文件**和**公钥**: + +```bash +dify signature verify your_plugin_project.signed.difypkg -p your_key_pair.public.pem +``` + +如果省略公钥参数,验证将使用 Dify 市场公钥。在这种情况下,对于任何未从 Dify 市场下载的插件文件,签名验证将失败。 + +## 启用第三方签名验证 + +Dify 管理员可以在安装插件前强制使用预先批准的公钥进行签名验证。 + +### 放置公钥 + +将用于签名的私钥对应的**公钥**放在插件守护程序可以访问的位置。 + +例如,在 `docker/volumes/plugin_daemon` 下创建 `public_keys` 目录,并将公钥文件复制到对应路径: + +```bash +mkdir docker/volumes/plugin_daemon/public_keys +cp your_key_pair.public.pem docker/volumes/plugin_daemon/public_keys +``` + +### 环境变量配置 + +在 `plugin_daemon` 容器中,配置以下环境变量: + +* `THIRD_PARTY_SIGNATURE_VERIFICATION_ENABLED` + * 启用第三方签名验证。 + * 将此项设置为 `true` 以启用此功能。 +* `THIRD_PARTY_SIGNATURE_VERIFICATION_PUBLIC_KEYS` + * 指定用于签名验证的公钥文件路径。 + * 你可以列出多个公钥文件,用逗号分隔。 + +以下是配置这些变量的 Docker Compose 覆盖文件 (`docker-compose.override.yaml`) 示例: + +```yaml +services: + plugin_daemon: + environment: + FORCE_VERIFYING_SIGNATURE: true + THIRD_PARTY_SIGNATURE_VERIFICATION_ENABLED: true + THIRD_PARTY_SIGNATURE_VERIFICATION_PUBLIC_KEYS: /app/storage/public_keys/your_key_pair.public.pem +``` + +请注意,`docker/volumes/plugin_daemon` 在 `plugin_daemon` 容器中被挂载到 `/app/storage`。确保在 `THIRD_PARTY_SIGNATURE_VERIFICATION_PUBLIC_KEYS` 中指定的路径对应于容器内的路径。 + +要应用这些更改,请重启 Dify 服务: + +```bash +cd docker +docker compose down +docker compose up -d +``` + +重启服务后,第三方签名验证功能将在当前社区版环境中启用。 diff --git a/zh-hans/plugins/quick-start/debug-plugin.mdx b/zh-hans/plugins/quick-start/debug-plugin.mdx index 3198cde2..44c80d35 100644 --- a/zh-hans/plugins/quick-start/debug-plugin.mdx +++ b/zh-hans/plugins/quick-start/debug-plugin.mdx @@ -7,7 +7,7 @@ title: 插件调试 前往[“插件管理”](https://cloud.dify.ai/plugins)页获取远程服务器地址和调试 Key。 -![](https://assets-docs.dify.ai/2024/12/053415ef127f1f4d6dd85dd3ae79626a.png) +![](https://assets-docs.dify.ai/2025/04/2779338a43687f3e00155baccdd6d06c.png) 回到插件项目,拷贝 `.env.example` 文件并重命名为 `.env`,将获取的远程服务器地址和调试 Key 等信息填入其中。 @@ -15,7 +15,7 @@ title: 插件调试 ```bash INSTALL_METHOD=remote -REMOTE_INSTALL_HOST=localhost +REMOTE_INSTALL_HOST=remote REMOTE_INSTALL_PORT=5003 REMOTE_INSTALL_KEY=****-****-****-****-**** ``` diff --git a/zh-hans/plugins/quick-start/develop-plugins/agent-strategy-plugin.mdx b/zh-hans/plugins/quick-start/develop-plugins/agent-strategy-plugin.mdx index 0ca1a574..e134bb48 100644 --- a/zh-hans/plugins/quick-start/develop-plugins/agent-strategy-plugin.mdx +++ b/zh-hans/plugins/quick-start/develop-plugins/agent-strategy-plugin.mdx @@ -2,7 +2,6 @@ title: Agent 策略插件 --- - Agent 策略插件能够帮助 LLM 执行推理或决策逻辑,包括工具选择、调用和结果处理,以更加自动化的方式处理问题。 本文将演示如何创建一个具备工具调用(Function Calling)能力,自动获取当前准确时间的插件。 @@ -12,57 +11,65 @@ Agent 策略插件能够帮助 LLM 执行推理或决策逻辑,包括工具选 * Dify 插件脚手架工具 * Python 环境,版本号 ≥ 3.12 -关于如何准备插件开发的脚手架工具,详细说明请参考[初始化开发工具](initialize-development-tools)。 +关于如何准备插件开发的脚手架工具,详细说明请参考[初始化开发工具](initialize-development-tools.md)。 - -**Tips**:在终端运行 `dify version` 命令,检查是否出现版本号以确认成功安装脚手架工具。 - +**Tips**:在终端运行 `dify version` 命令,检查是否出现版本号以确认成功安装脚手架工具。 ### 1. 初始化插件模板 运行以下命令,初始化 Agent 插件开发模板。 -``` +```bash dify plugin init ``` 按照页面提示,填写对应信息。参考以下代码中的备注信息,进行设置。 -``` -➜ Dify Plugins Developing dify plugin init +```bash +➜ ./dify-plugin-darwin-arm64 plugin init ─╯ Edit profile of the plugin Plugin name (press Enter to next step): # 填写插件的名称 -Author (press Enter to next step): Author name # 填写插件作者 -Description (press Enter to next step): Description # 填写插件的描述 +Author (press Enter to next step): # 填写插件作者 +Description (press Enter to next step): # 填写插件的描述 --- -Select the language you want to use for plugin development, and press Enter to con +Select the language you want to use for plugin development, and press Enter to continue, BTW, you need Python 3.12+ to develop the Plugin if you choose Python. -> python # 选择 Python 环境 go (not supported yet) --- -Based on the ability you want to extend, we have divided the Plugin into four type +Based on the ability you want to extend, we have divided the Plugin into four types: Tool, Model, Extension, and Agent Strategy. -- Tool: It's a tool provider, but not only limited to tools, you can implement an +- Tool: It's a tool provider, but not only limited to tools, you can implement an endpoint there, for example, you need both Sending Message and Receiving Message if you are - Model: Just a model provider, extending others is not allowed. -- Extension: Other times, you may only need a simple http service to extend the fu +- Extension: Other times, you may only need a simple http service to extend the functionalities, Extension is the right choice for you. - Agent Strategy: Implement your own logics here, just by focusing on Agent itself -What's more, we have provided the template for you, you can choose one of them b +What's more, we have provided the template for you, you can choose one of them below: tool -> agent-strategy # 选择 Agent 策略模板 llm text-embedding --- -Configure the permissions of the plugin, use up and down to navigate, tab to sel +Configure the permissions of the plugin, use up and down to navigate, tab to select, after selection, press enter to finish Backwards Invocation: Tools: Enabled: [✔] You can invoke tools inside Dify if it's enabled # 默认开启 Models: Enabled: [✔] You can invoke models inside Dify if it's enabled # 默认开启 LLM: [✔] You can invoke LLM models inside Dify if it's enabled # 默认开启 - Text Embedding: [✘] You can invoke text embedding models inside Dify if it' + → Text Embedding: [✘] You can invoke text embedding models inside Dify if it's enabled Rerank: [✘] You can invoke rerank models inside Dify if it's enabled -... + TTS: [✘] You can invoke TTS models inside Dify if it's enabled + Speech2Text: [✘] You can invoke speech2text models inside Dify if it's enabled + Moderation: [✘] You can invoke moderation models inside Dify if it's enabled +Apps: + Enabled: [✘] Ability to invoke apps like BasicChat/ChatFlow/Agent/Workflow etc. +Resources: +Storage: + Enabled: [✘] Persistence storage for the plugin + Size: N/A The maximum size of the storage +Endpoints: + Enabled: [✘] Ability to register endpoints ``` 初始化插件模板后将生成一个代码文件夹,包含插件开发过程中所需的完整资源。熟悉 Agent 策略插件的整体代码结构有助于插件的开发过程。 @@ -186,7 +193,7 @@ class BasicAgentAgentStrategy(AgentStrategy): params = BasicParams(**parameters) ``` -#### 3. 调用模型 +#### 2.3 调用模型 在 Agent 策略插件中,**调用模型**是核心执行逻辑之一。可以通过 SDK 提供的 `session.model.llm.invoke()` 方法高效地调用 LLM 模型,实现文本生成、对话处理等功能。 @@ -219,7 +226,95 @@ def invoke( ![生成工具的请求参数](https://assets-docs.dify.ai/2025/01/01e32c2d77150213c7c929b3cceb4dae.png) -#### 4. 调用工具 +#### 2.4 为模型添加记忆 + +当使用 Agent 插件调用模型时,为模型添加记忆功能能够极大提升对话体验。通过记忆功能,模型可以理解完整的对话上下文,实现连贯的交互体验和精准的工具调用。 + +具体实现步骤: + +1. 配置记忆功能 + +在 Agent 插件的 YAML 配置文件 `strategies/agent.yaml` 中添加 `history-messages` 特性: + +```yaml +identity: + name: basic_agent # Agent策略名称 + author: novice # 作者 + label: + en_US: BasicAgent # 英文标签 +description: + en_US: BasicAgent # 英文描述 +features: + - history-messages # 启用历史消息功能 +... +``` + +2. 启用记忆设置 + +修改插件配置文件并重启后,你将在节点配置界面中看到 **记忆** 开关。点击右侧的开关按钮,启用记忆功能。 + +

+ Memory +

+ +启用后,您可以通过 **窗口大小** 滑块调整记忆窗口,它决定了模型能够“记住”多少之前的对话内容。 + +3. 调试历史消息 + +添加以下代码,查看历史消息内容: + +```python +class BasicAgentAgentStrategy(AgentStrategy): + def _invoke(self, parameters: dict[str, Any]) -> Generator[AgentInvokeMessage]: + params = BasicParams(**parameters) + print(f"history_messages: {params.model.history_prompt_messages}") + ... +``` + +![History messages](https://assets-docs.dify.ai/2025/04/cb11fae7981dae431966f83fa99f1dfb.png) + +控制台将显示类似如下输出: + +``` +history_messages: [] +history_messages: [UserPromptMessage(role=, content='hello, my name is novice', name=None), AssistantPromptMessage(role=, content='Hello, Novice! How can I assist you today?', name=None, tool_calls=[])] +``` + +4. 将历史消息集成到模型调用 + +最后,修改模型调用代码,将历史消息拼接到当前查询: + +```python +class BasicAgentAgentStrategy(AgentStrategy): + def _invoke(self, parameters: dict[str, Any]) -> Generator[AgentInvokeMessage]: + params = BasicParams(**parameters) + + chunks: Generator[LLMResultChunk, None, None] | LLMResult = ( + self.session.model.llm.invoke( + model_config=LLMModelConfig(**params.model.model_dump(mode="json")), + # 添加历史消息 + prompt_messages=params.model.history_prompt_messages + + [UserPromptMessage(content=params.query)], + tools=[ + self._convert_tool_to_prompt_message_tool(tool) + for tool in params.tools + ], + stop=params.model.completion_params.get("stop", []) + if params.model.completion_params + else [], + stream=True, + ) + ) + ... +``` + +5. 效果验证 + +添加加记忆功能后,模型能够基于历史对话进行回复。在下图示例中,模型成功地记住了之前对话中提及的用户名称,实现了对话的连贯性。 + +![Outcome](https://assets-docs.dify.ai/2025/04/6bdd3d2c6a455ae8e463bd6abab5c3a4.png) + +#### 2.5 调用工具 填写工具参数后,需赋予 Agent 策略插件实际调用工具的能力。可以通过 SDK 中的`session.tool.invoke()` 函数进行工具调用。 @@ -263,7 +358,7 @@ for tool_call_id, tool_call_name, tool_call_args in tool_calls: ![工具调用](https://assets-docs.dify.ai/2025/01/80e5de8acc2b0ed00524e490fd611ff5.png) -#### 5. 日志创建 +#### 2.6 日志创建 在 **Agent 策略插件**中,通常需要执行多轮操作才能完成复杂任务。记录每轮操作的执行结果对于开发者来说非常重要,有助于追踪 Agent 的执行过程、分析每一步的决策依据,从而更好地评估和优化策略效果。 @@ -326,15 +421,15 @@ model_log = self.create_log_message( yield model_log ``` -#### 插件功能示例代码 +### 插件功能示例代码 - - #### 调用模型 + +#### 调用模型 以下代码将演示如何赋予 Agent 策略插件调用模型的能力: -```python [expandable] +```python import json from collections.abc import Generator from typing import Any, cast @@ -554,13 +649,14 @@ class BasicAgentAgentStrategy(AgentStrategy): return tool_calls ``` - - - #### 调用工具 + + + +#### 调用工具 以下代码展示了如何为 Agent 策略插件实现模型调用并向工具发送规范化请求。 -```python [expandable] +```python import json from collections.abc import Generator from typing import Any, cast @@ -780,13 +876,14 @@ class BasicAgentAgentStrategy(AgentStrategy): return tool_calls ``` - - - #### 完整功能代码示例 + + + +#### 完整功能代码示例 包含**调用模型、调用工具**以及**输出多轮日志功能**的完整插件代码示例: -```python [expandable] +```python import json import time from collections.abc import Generator @@ -1037,33 +1134,34 @@ class BasicAgentAgentStrategy(AgentStrategy): return tool_calls ``` - + ### 3. 调试插件 配置插件的声明文件与功能代码后,在插件的目录内运行 `python -m main` 命令重启插件。接下来需测试插件是否可以正常运行。Dify 提供远程调试方式,前往[“插件管理”](https://console-plugin.dify.dev/plugins)获取调试 Key 和远程服务器地址。 -![](https://assets-docs.dify.ai/2024/12/053415ef127f1f4d6dd85dd3ae79626a.png) +
回到插件项目,拷贝 `.env.example` 文件并重命名为 `.env`,将获取的远程服务器地址和调试 Key 等信息填入至 `REMOTE_INSTALL_HOST` 与 `REMOTE_INSTALL_KEY` 参数内。 ```bash INSTALL_METHOD=remote -REMOTE_INSTALL_HOST=localhost +REMOTE_INSTALL_HOST=remote REMOTE_INSTALL_PORT=5003 REMOTE_INSTALL_KEY=****-****-****-****-**** ``` 运行 `python -m main` 命令启动插件。在插件页即可看到该插件已被安装至 Workspace 内。其他团队成员也可以访问该插件。 -![访问插件](https://assets-docs.dify.ai/2025/01/c82ec0202e5bf914b36e06c796398dd6.png) +

访问插件

### 打包插件(可选) 确认插件能够正常运行后,可以通过以下命令行工具打包并命名插件。运行以后你可以在当前文件夹发现 `google.difypkg` 文件,该文件为最终的插件包。 -``` +```bash +# 将 ./basic_agent 替换为插件项目的实际路径 dify plugin package ./basic_agent/ ``` diff --git a/zh-hans/plugins/quick-start/develop-plugins/model-plugin/customizable-model.mdx b/zh-hans/plugins/quick-start/develop-plugins/model-plugin/customizable-model.mdx index 8c53e97e..732f221f 100644 --- a/zh-hans/plugins/quick-start/develop-plugins/model-plugin/customizable-model.mdx +++ b/zh-hans/plugins/quick-start/develop-plugins/model-plugin/customizable-model.mdx @@ -323,7 +323,7 @@ def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]] 如果想要将插件发布至 Dify Marketplace,请参考以下内容: - + publish-to-dify-marketplace diff --git a/zh-hans/plugins/quick-start/develop-plugins/tool-plugin.mdx b/zh-hans/plugins/quick-start/develop-plugins/tool-plugin.mdx index 2cd88378..720ee25a 100644 --- a/zh-hans/plugins/quick-start/develop-plugins/tool-plugin.mdx +++ b/zh-hans/plugins/quick-start/develop-plugins/tool-plugin.mdx @@ -211,7 +211,7 @@ extra: * `identity` 包含了工具的基本信息,包括名称、作者、标签、描述等。 * `parameters` 参数列表 * `name` (必填)参数名称,唯一,不允许和其他参数重名。 - * `type` (必填)参数类型,目前支持`string`、`number`、`boolean`、`select`、`secret-input` 五种类型,分别对应字符串、数字、布尔值、下拉框、加密输入框,对于敏感信息,请使用`secret-input`类型。 + * `type` (必填)参数类型,目前支持`string`、`number`、`boolean`、`select`、`secret-input`、`file`、`files`、`model-selector`、`app-selector` 九种类型,分别对应字符串、数字、布尔值、下拉框、加密输入框、文件、文件集、模型选择、应用选择,对于敏感信息,请使用 `secret-input` 类型。 * `label`(必填)参数标签,用于前端展示。 * `form` (必填)表单类型,目前支持`llm`、`form`两种类型。 * 在 Agent 应用中,`llm` 表示该参数 LLM 自行推理,`form` 表示要使用该工具可提前设定的参数。 @@ -318,7 +318,7 @@ class GoogleProvider(ToolProvider): ```bash INSTALL_METHOD=remote -REMOTE_INSTALL_HOST=localhost +REMOTE_INSTALL_HOST=remote REMOTE_INSTALL_PORT=5003 REMOTE_INSTALL_KEY=****-****-****-****-**** ``` diff --git a/zh-hans/plugins/schema-definition/manifest.mdx b/zh-hans/plugins/schema-definition/manifest.mdx index 13d417a1..d24c014c 100644 --- a/zh-hans/plugins/schema-definition/manifest.mdx +++ b/zh-hans/plugins/schema-definition/manifest.mdx @@ -47,11 +47,15 @@ meta: - "arm64" runner: language: "python" - version: "3.10" + version: "3.11" entrypoint: "main" privacy: "./privacy.md" ``` +### 版本管理 + +插件的版本由 `manifest` 文件中的 `version` 字段管理。版本号必须符合 `大版本.小版本.补丁版本` 格式,否则自动更新可能无法正常工作。 + ### 结构 * `version`(version, required):插件的版本 diff --git a/zh-hans/plugins/schema-definition/reverse-invocation-of-the-dify-service/model.mdx b/zh-hans/plugins/schema-definition/reverse-invocation-of-the-dify-service/model.mdx index e36e8f23..160b8a00 100644 --- a/zh-hans/plugins/schema-definition/reverse-invocation-of-the-dify-service/model.mdx +++ b/zh-hans/plugins/schema-definition/reverse-invocation-of-the-dify-service/model.mdx @@ -17,7 +17,7 @@ title: Model self.session.model.llm ``` -#### **接口** +#### **端点** ```python def invoke( @@ -159,7 +159,7 @@ class LLMTool(Tool): ### 调用 Summary -你可以请求该接口来总结一段文本,它会使用你当前 workspace 内的系统模型来总结文本。 +你可以请求该端点来总结一段文本,它会使用你当前 workspace 内的系统模型来总结文本。 **入口** @@ -167,7 +167,7 @@ class LLMTool(Tool): self.session.model.summary ``` -**接口** +**端点** * `text` 为需要被总结的文本。 * `instruction` 为你想要额外添加的指令,它可以让你风格化地总结文本。 @@ -186,7 +186,7 @@ class LLMTool(Tool): self.session.model.text_embedding ``` -**接口** +**端点** ```python def invoke( @@ -203,7 +203,7 @@ class LLMTool(Tool): self.session.model.rerank ``` -**接口** +**端点** ```python def invoke( @@ -220,7 +220,7 @@ class LLMTool(Tool): self.session.model.tts ``` -**接口** +**端点** ```python def invoke( @@ -229,7 +229,7 @@ class LLMTool(Tool): pass ``` -请注意 `tts` 接口返回的 `bytes` 流是一个 `mp3` 音频字节流,每一轮迭代返回的都是一个完整的音频。如果你想做更深入的处理任务,请选择合适的库进行。 +请注意 `tts` 端点返回的 `bytes` 流是一个 `mp3` 音频字节流,每一轮迭代返回的都是一个完整的音频。如果你想做更深入的处理任务,请选择合适的库进行。 ### 调用 Speech2Text @@ -239,7 +239,7 @@ class LLMTool(Tool): self.session.model.speech2text ``` -**接口** +**端点** ```python def invoke( @@ -258,11 +258,11 @@ class LLMTool(Tool): self.session.model.moderation ``` -**接口** +**端点** ```python def invoke(self, model_config: ModerationModelConfig, text: str) -> bool: pass ``` -若该接口返回 `true` 则表示 `text` 中包含敏感内容。 +若该端点返回 `true` 则表示 `text` 中包含敏感内容。 diff --git a/zh-hans/url-report/link-check-report.md b/zh-hans/url-report/link-check-report.md index 24136c04..a6650edd 100644 --- a/zh-hans/url-report/link-check-report.md +++ b/zh-hans/url-report/link-check-report.md @@ -30,7 +30,7 @@ * [负载均衡](guides/model-configuration/load-balancing) ✅ | [订阅 SaaS 付费服务](../../getting-started/cloud.md#ding-yue-ji-hua) ✅ * [构建应用](guides/application-orchestrate/README) ✅ * [创建应用](guides/application-orchestrate/creating-an-application) ✅ | [应用管理:导入](https://docs.dify.ai/zh-hans/guides/management/app-management#dao-ru-ying-yong) ✅ - * [聊天助手](guides/application-orchestrate/chatbot-application) ✅ | [知识库](../knowledge-base/) ✅ | [Claude 3.5 Sonnet](https://docs.anthropic.com/en/docs/build-with-claude/pdf-support) ✅ | [Gemini 1.5 Pro](https://ai.google.dev/api/files) ✅ | [多模型调试](./multiple-llms-debugging) ✅ | [发布](https://docs.dify.ai/v/zh-hans/guides/application-publishing) ✅ | [WebApp 的模版](https://github.com/langgenius/webapp-conversation) ✅ | [Agent 类型](https://docs.dify.ai/v/zh-hans/guides/application-orchestrate/agent) ✅ | [在应用内集成知识库](https://docs.dify.ai/zh-hans/guides/knowledge-base/integrate-knowledge-within-application) ✅ + * [聊天助手](guides/application-orchestrate/chatbot-application) ✅ | [知识库](../knowledge-base/) ✅ | [Claude 3.5 Sonnet](https://docs.anthropic.com/en/docs/build-with-claude/pdf-support) ✅ | [Gemini 1.5 Pro](https://ai.google.dev/api/files) ✅ | [多模型调试](./multiple-llms-debugging) ✅ | [发布](https://docs.dify.ai/v/zh-hans/guides/application-publishing) ✅ | [WebApp 的模板](https://github.com/langgenius/webapp-conversation) ✅ | [Agent 类型](https://docs.dify.ai/v/zh-hans/guides/application-orchestrate/agent) ✅ | [在应用内集成知识库](https://docs.dify.ai/zh-hans/guides/knowledge-base/integrate-knowledge-within-application) ✅ * [多模型调试](guides/application-orchestrate/multiple-llms-debugging) ✅ | [“增加新供应商”](https://docs.dify.ai/v/zh-hans/guides/model-configuration/new-provider) ✅ * [Agent](guides/application-orchestrate/agent) ✅ | [Claude 3.5 Sonnet](https://docs.anthropic.com/en/docs/build-with-claude/pdf-support) ✅ | [Gemini 1.5 Pro](https://ai.google.dev/api/files) ✅ * [应用工具箱](guides/application-orchestrate/app-toolkits/README) ✅ | [应用](../#application_type) ✅ | [引用与归属](../../knowledge-base/retrieval-test-and-citation.md#id-2-yin-yong-yu-gui-shu) ✅ | [敏感内容审查](moderation-tool) ✅ | [标注回复](../../annotation/annotation-reply) ✅