Allow you to store and manipulate collections of data. They can be declared in a concise and readable manner, supporting both single-line and multi-line formats.

Syntax

To declare an array in a BAML file, you can use the following syntax:

1{
2 key1 [value1, value2, value3],
3 key2 [
4 value1,
5 value2,
6 value3
7 ],
8 key3 [
9 {
10 subkey1 "valueA",
11 subkey2 "valueB"
12 },
13 {
14 subkey1 "valueC",
15 subkey2 "valueD"
16 }
17 ]
18}

Key Points:

  • Commas: Optional for multi-line arrays, but recommended for clarity.
  • Nested Arrays: Supported, allowing complex data structures.
  • Key-Value Pairs: Arrays can contain objects with key-value pairs.

Usage Examples

Example 1: Simple Array

1function DescriptionGame(items: string[]) -> string {
2 client "openai/gpt-4o-mini"
3 prompt #"
4 What 3 words best describe all of these: {{ items }}.
5 "#
6}
7
8test FruitList {
9 functions [DescriptionGame]
10 args { items ["apple", "banana", "cherry"] }
11}

Example 2: Multi-line Array

1test CityDescription {
2 functions [DescriptionGame]
3 args { items [
4 "New York",
5 "Los Angeles",
6 "Chicago"
7 ]
8 }
9}