mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-03-27 13:28:32 +07:00
* fix redirect language code prefixes * rename: cn -> zh, jp -> ja * remove hardcoded ja / zh references * remove hardcoded 'english' references * renamed variable names and dict keys to language agnostic names * fix: add missing language helper methods to PRAnalyzer - Add get_language_directory() method - Initialize source_language and target_languages from config - Fixes AttributeError when generating mixed PR errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * test: kitchen sink workflow validation v2 This PR validates the translation workflow after config-driven refactoring: Changes: - Add new test file: test-workflow-validation.mdx - Modify existing file: introduction.mdx - Update docs.json navigation Tests: - New file translation (add workflow) - Existing file translation (update workflow) - Navigation sync across languages - Config-driven language codes (zh/ja instead of cn/jp) - Source language abstraction (no hardcoded "English") Expected workflow behavior: 1. Detect changes in en/ directory 2. Translate new file to zh and ja 3. Update modified file translations 4. Sync docs.json for all language sections 5. Commit translated files automatically 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: update workflow paths to use zh/ja instead of cn/jp Aligns workflow trigger paths with the zh/ja language directory rename. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Revert "fix: update workflow paths to use zh/ja instead of cn/jp" This reverts commit9587b7cc5d. * Revert "test: kitchen sink workflow validation v2" This reverts commit4abdd69fd2. * fix: update workflow paths in doc analyze workflow to use zh/ja instead of cn/jp * Refactor/language codes (#240) * test: kitchen sink workflow validation v2 This PR validates the translation workflow after config-driven refactoring: Changes: - Add new test file: test-workflow-validation.mdx - Modify existing file: introduction.mdx - Update docs.json navigation Tests: - New file translation (add workflow) - Existing file translation (update workflow) - Navigation sync across languages - Config-driven language codes (zh/ja instead of cn/jp) - Source language abstraction (no hardcoded "English") Expected workflow behavior: 1. Detect changes in en/ directory 2. Translate new file to zh and ja 3. Update modified file translations 4. Sync docs.json for all language sections 5. Commit translated files automatically 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: update workflow paths to use zh/ja instead of cn/jp Aligns workflow trigger paths with the zh/ja language directory rename. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Revert "fix: update workflow paths to use zh/ja instead of cn/jp" This reverts commit9587b7cc5d. * Revert "test: kitchen sink workflow validation v2" This reverts commit4abdd69fd2. * fix: update workflow paths in doc analyze workflow to use zh/ja instead of cn/jp --------- Co-authored-by: Claude <noreply@anthropic.com> * fix: update workflow files to use 'source' instead of 'english' After refactoring the PR analyzer to use 'source' for source language PRs (instead of hardcoded 'english'), the workflow files need to match. Changes: - sync_docs_analyze.yml: pr_type == 'source' (was 'english') - sync_docs_update.yml: PR_TYPE != 'source' check - Updated all comments from "English" to "source language" - Updated all pr_type values in JSON from "english" to "source" This ensures the workflows trigger correctly with the refactored config-driven language system. Related: language code refactoring (cn/jp → zh/ja) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix/workflow source language references (#245) * test: kitchen sink workflow validation v2 This PR validates the translation workflow after config-driven refactoring: Changes: - Add new test file: test-workflow-validation.mdx - Modify existing file: introduction.mdx - Update docs.json navigation Tests: - New file translation (add workflow) - Existing file translation (update workflow) - Navigation sync across languages - Config-driven language codes (zh/ja instead of cn/jp) - Source language abstraction (no hardcoded "English") Expected workflow behavior: 1. Detect changes in en/ directory 2. Translate new file to zh and ja 3. Update modified file translations 4. Sync docs.json for all language sections 5. Commit translated files automatically 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: update workflow paths to use zh/ja instead of cn/jp Aligns workflow trigger paths with the zh/ja language directory rename. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Revert "fix: update workflow paths to use zh/ja instead of cn/jp" This reverts commit9587b7cc5d. * Revert "test: kitchen sink workflow validation v2" This reverts commit4abdd69fd2. * fix: update workflow paths in doc analyze workflow to use zh/ja instead of cn/jp * fix: update workflow files to use 'source' instead of 'english' After refactoring the PR analyzer to use 'source' for source language PRs (instead of hardcoded 'english'), the workflow files need to match. Changes: - sync_docs_analyze.yml: pr_type == 'source' (was 'english') - sync_docs_update.yml: PR_TYPE != 'source' check - Updated all comments from "English" to "source language" - Updated all pr_type values in JSON from "english" to "source" This ensures the workflows trigger correctly with the refactored config-driven language system. Related: language code refactoring (cn/jp → zh/ja) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> * fix * fix docs.json language codes * rename previous version docs: cn -> zh, jp -> ja * rm duplicate redirect entires --------- Co-authored-by: Claude <noreply@anthropic.com>
120 lines
5.4 KiB
Plaintext
120 lines
5.4 KiB
Plaintext
---
|
||
title: "ループ"
|
||
description: "段階的な改良で反復的なワークフローを実行"
|
||
icon: "infinity"
|
||
---
|
||
|
||
<Note> ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/use-dify/nodes/loop)を参照してください。</Note>
|
||
|
||
|
||
ループノードは、各サイクルが前のサイクルの結果をベースに構築される反復的なワークフローを実行します。配列要素を独立して処理するイテレーションとは異なり、ループは各反復で進化する段階的なワークフローを作成します。
|
||
|
||
## ループ vs イテレーション
|
||
|
||
各反復パターンをいつ使用するかを理解する:
|
||
|
||
<Tabs>
|
||
<Tab title="ループ">
|
||
**順次処理** - 各サイクルは前の結果に依存する
|
||
|
||
**段階的改良** - 出力が反復を通じて改善または進化する
|
||
|
||
**状態管理** - 変数がサイクル全体で持続し蓄積される
|
||
|
||
**ユースケース** - コンテンツ改良、問題解決、品質保証
|
||
</Tab>
|
||
|
||
<Tab title="イテレーション">
|
||
**独立処理** - 各アイテムが個別に処理される
|
||
|
||
**並列実行** - アイテムを同時に処理できる
|
||
|
||
**バッチ操作** - 同じ操作を複数のデータポイントに適用
|
||
|
||
**ユースケース** - データ変換、一括処理、並列分析
|
||
</Tab>
|
||
</Tabs>
|
||
|
||
## 設定
|
||
|
||
### ループ変数
|
||
|
||
ループの反復全体で持続し、ループ完了後もアクセス可能な変数を定義します。これらの変数は状態を維持し、段階的なワークフローを可能にします。
|
||
|
||
### 終了条件
|
||
|
||
ループの実行を停止するタイミングを設定:
|
||
|
||
**ループ終了条件** - 終了するタイミングを決定する式(例:`quality_score > 0.9`)
|
||
|
||
**最大ループ回数** - 無限ループを防ぐための安全制限
|
||
|
||
**ループ終了ノード** - このノードに到達した時の即座の終了
|
||
|
||
<Info>
|
||
ループは、終了条件が満たされる、最大回数に達する、またはループ終了ノードが実行されるときに終了します。条件が指定されていない場合、ループは最大回数まで継続されます。
|
||
</Info>
|
||
|
||
## 基本ループの例
|
||
|
||
50未満の数値が見つかるまでランダムな数値を生成:
|
||
|
||
<Frame caption="ランダム数値生成の基本ループワークフロー">
|
||
<img src="https://assets-docs.dify.ai/2025/04/282013c48b46d3cc4ebf99323da10a31.png" alt="基本ループワークフロー" />
|
||
</Frame>
|
||
|
||
**ワークフローステップ:**
|
||
1. **コードノード**が1-100のランダムな整数を生成
|
||
2. **If-Elseノード**が数値が50未満かをチェック
|
||
3. **テンプレートノード**が50未満の数値に対して「完了」を返しループ終了をトリガー
|
||
4. 終了条件が満たされるまでループが継続
|
||
|
||
<Frame caption="ループ実行ステップと結果">
|
||
<img src="https://assets-docs.dify.ai/2025/04/9d9fb4db7093521000ac735a26f86962.png" alt="ループ実行ステップ" />
|
||
</Frame>
|
||
|
||
## 高度なループの例
|
||
|
||
反復的改良によって詩を作成し、各バージョンが前のバージョンをベースに構築:
|
||
|
||
<video controls src="https://assets-docs.dify.ai/2025/04/7ecfc04458aa38e721baaa5f6355486c.mp4" width="100%" />
|
||
|
||
**ループ変数:**始し、各反復でインクリメントするカウンター
|
||
- `verse` - 現在の詩のバージョンを保持するテキスト変数
|
||
|
||
**ワークフローロジック:**
|
||
1. **If-Elseノード**が`num > 3`をチェックして終了タイミングを決定
|
||
2. **大規模言語モデルノード**が前のバージョンをベースに改良された詩を生成
|
||
3. **変数アサイナー**がカウンターと詩の内容を更新
|
||
4. **ループ終了ノード**が4回の改良サイクル後に終了
|
||
|
||
大規模言語モデルのプロンプトは現在の詩と反復コンテキストの両方を参照:
|
||
|
||
```text
|
||
You are a European literary figure creating poetic verses.
|
||
|
||
Current verse: {{verse}}
|
||
|
||
Refine and improve this poem based on your previous work.
|
||
```
|
||
|
||
## 一般的なユースケース
|
||
|
||
**コンテンツ改良** - 品質基準が満たされるまで、複数の大規模言語モデルレビューを通じてテキスト、コード、またはデザインを段階的に改善。
|
||
|
||
**問題解決** - 複雑な問題を反復的なステップに分割し、各サイクルが前の進捗に基づいて次の論理的な部分に取り組む。
|
||
|
||
**研究ワークフロー** - 各検索サイクルの結果に基づいて、研究クエリを反復的に検索、分析、改良。
|
||
|
||
**品質保証** - すべての基準が満たされるまで、出力を繰り返しテストし検証し、改善を実施。
|
||
|
||
## ベストプラクティス
|
||
|
||
**明確な終了条件の定義** - 無限実行を防ぐため、ループが終了のための具体的で測定可能な条件を持つことを確保。
|
||
|
||
**適切な制限の設定** - 期待される複雑さと処理要件に基づいて、適切な最大反復回数を使用。
|
||
|
||
**効果的な状態管理** - 不要なデータ蓄積を避けながら、反復間で必要な情報を維持するためにループ変数を使用。
|
||
|
||
**進捗の監視** - 特に長時間実行されるプロセスについて、ループ実行を追跡するためのログや進捗インジケーターを含める。
|