choice

Contents

choice#

class langworks.dsl.constraints.choice.Choice#

Specifies a limited list of options the LLM may choose from during generation.

In its minimal form, the constraint can be applied as follows:

```
The sentiment is: {% choice ["positive", "negative"] %}.
```

As subclass of Constraint, any of the default arguments may also be passed:

```
The answer is {% 
    choice ["positive", "negative"], var = "sentiment", params = Params(max_tokens = 1) 
%}
```

Properties#

spec: tuple[str] = None#

The list of options that the LLM may choose from.