@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
class MyClass {
property1 string
}

ctx.output_format:

{
property1: string
}

With @description

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

ctx.output_format:

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

Prompt Impact (enum - value)

Without @description

BAML
enum MyEnum {
Value1
Value2
}

ctx.output_format:

MyEnum
---
Value1
Value2

With @description

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

ctx.output_format:

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

Prompt Impact (enum)

BAML
enum MyEnum {
Value1
Value2
@@description("This enum represents status codes")
}

ctx.output_format:

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