@description / @@description

The @description attribute in BAML provides additional context to fields or values in prompts. This can help the LLM understand the intended use or meaning of a field or value.

Prompt Impact

Without @description

BAML
1class MyClass {
2 property1 string
3}

ctx.output_format:

{
property1: string
}

With @description

BAML
1class MyClass {
2 property1 string @description("The name of the object")
3}

ctx.output_format:

{
// The name of the object
property1: string
}

Prompt Impact (enum - value)

Without @description

BAML
1enum MyEnum {
2 Value1
3 Value2
4}

ctx.output_format:

MyEnum
---
Value1
Value2

With @description

BAML
1enum MyEnum {
2 Value1 @description("The first value")
3 Value2 @description("The second value")
4}

ctx.output_format:

MyEnum
---
Value1 // The first value
Value2 // The second value

Prompt Impact (enum)

BAML
1enum MyEnum {
2 Value1
3 Value2
4
5 @@description("This enum represents status codes")
6}

ctx.output_format:

MyEnum: This enum represents status codes
---
Value1
Value2