> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Dict Condition • Rust AI Agent SDK

> DictCondition: Dictionary-based condition for routing. Maps values to target tasks/steps.

# DictCondition

> Defined in the [**conditions**](../modules/conditions) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Dictionary-based condition for routing. Maps values to target tasks/steps.

## Fields

| Name       | Type                | Description                       |
| ---------- | ------------------- | --------------------------------- |
| `variable` | `String`            | Variable name to check            |
| `routes`   | `HashMap&lt;String` | Mapping of values to target tasks |
| `default`  | `Vec&lt;String&gt;` | Default targets if no match       |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(variable: impl Into<String>) -> Self
```

Create a new dict condition.

**Parameters:**

| Name       | Type                      |
| ---------- | ------------------------- |
| `variable` | `impl Into&lt;String&gt;` |

### `when`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn when(mut self, value: impl Into<String>, targets: Vec<String>) -> Self
```

Add a route for a value.

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `value`   | `impl Into&lt;String&gt;` |
| `targets` | `Vec&lt;String&gt;`       |

### `default_targets`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn default_targets(mut self, targets: Vec<String>) -> Self
```

Set default targets.

**Parameters:**

| Name      | Type                |
| --------- | ------------------- |
| `targets` | `Vec&lt;String&gt;` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/conditions/mod.rs#L191">
  `praisonai/src/conditions/mod.rs` at line 191
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Conditions" icon="code-branch" href="/docs/rust/conditions" />

  <Card title="Rust Routing" icon="route" href="/docs/rust/routing" />
</CardGroup>
