循环工作流

Overview

概述

In our previous tutorials, we explored sequential and parallel workflows in ADK. Now, we’ll dive into the third major workflow pattern: looping workflows.

在我们的 之前的教程 中,我们探讨了 ADK 中的顺序和并行工作流。现在,我们将深入研究第三种主要工作流模式:循环工作流。

Looping workflows allow agents to repeat a process multiple times, refining their outputs until they meet specific criteria or achieve a desired outcome. This pattern is particularly useful for tasks that require multiple iterations to reach an optimal solution, such as content refinement, complex problem-solving, or optimization challenges.

循环工作流允许代理多次重复一个过程,精炼他们的输出,直到满足特定标准或实现期望的结果。这个模式对于需要多次迭代以达到最佳解决方案的任务特别有用,例如内容精炼、复杂问题解决或优化挑战。

Why Use Looping Workflows?

为什么使用循环工作流?

Looping workflows offer several key advantages:

循环工作流提供了几个关键优势:

  1. Iterative Refinement: Gradually improve outputs through multiple passes
  2. 迭代精炼: 通过多次传递逐步改善输出
  3. Quality Control: Continue processing until specific quality thresholds are met
  4. 质量控制: 继续处理直到达到特定的质量阈值
  5. Complex Problem Solving: Break down difficult problems into manageable iterations
  6. 复杂问题解决: 将困难问题分解为可管理的迭代
  7. Self-Correction: Allow agents to learn from previous attempts
  8. 自我纠正: 允许代理从之前的尝试中学习
  9. Optimization: Find better solutions through successive approximation
  10. 优化: 通过连续逼近找到更好的解决方案

Understanding Looping Patterns in ADK

理解ADK中的循环模式

While ADK doesn’t provide built-in primitives specifically for looping, we can implement looping workflows using Python’s control structures. The two primary looping patterns are:

虽然ADK没有提供专门用于循环的内置原语,但我们可以使用Python的控制结构实现循环工作流。两种主要的循环模式是:

  1. Count-based loops: Iterate a fixed number of times
  2. 基于计数的循环:迭代固定次数
  3. Condition-based loops: Iterate until a specific condition is met
  4. 基于条件的循环:迭代直到满足特定条件

In this tutorial, we’ll implement both patterns to demonstrate how looping can enhance agent capabilities.

在本教程中,我们将实现这两种模式,以演示循环如何增强代理的能力。

Building a Content Refinement System

构建内容精炼系统

Let’s create a looping workflow that iteratively refines content based on specific criteria. Our system will:

让我们创建一个循环工作流程,基于特定标准迭代地优化内容。我们的系统将:

  1. Generate initial content based on a ...
开通本站会员,查看完整译文。

trang chủ - Wiki
Copyright © 2011-2025 iteam. Current version is 2.144.0. UTC+08:00, 2025-07-05 01:14
浙ICP备14020137号-1 $bản đồ khách truy cập$