BAML language preview
1. Extract function
a function signature, a prompt block, and a client config
horizon-dark
// extract a resume from raw text
function Extract(text: string) -> Resume {
client GPT4
prompt #"
Extract the resume from this text: {{ text }}
{{ ctx.output_format }}
"#
}
client<llm> GPT4 {
provider openai
options {
model "gpt-4o"
}
} atom-one-dark
// extract a resume from raw text
function Extract(text: string) -> Resume {
client GPT4
prompt #"
Extract the resume from this text: {{ text }}
{{ ctx.output_format }}
"#
}
client<llm> GPT4 {
provider openai
options {
model "gpt-4o"
}
} github-dark
// extract a resume from raw text
function Extract(text: string) -> Resume {
client GPT4
prompt #"
Extract the resume from this text: {{ text }}
{{ ctx.output_format }}
"#
}
client<llm> GPT4 {
provider openai
options {
model "gpt-4o"
}
} dracula
// extract a resume from raw text
function Extract(text: string) -> Resume {
client GPT4
prompt #"
Extract the resume from this text: {{ text }}
{{ ctx.output_format }}
"#
}
client<llm> GPT4 {
provider openai
options {
model "gpt-4o"
}
} nord
// extract a resume from raw text
function Extract(text: string) -> Resume {
client GPT4
prompt #"
Extract the resume from this text: {{ text }}
{{ ctx.output_format }}
"#
}
client<llm> GPT4 {
provider openai
options {
model "gpt-4o"
}
} github
// extract a resume from raw text
function Extract(text: string) -> Resume {
client GPT4
prompt #"
Extract the resume from this text: {{ text }}
{{ ctx.output_format }}
"#
}
client<llm> GPT4 {
provider openai
options {
model "gpt-4o"
}
} 2. Class with attributes
@description and @@dynamic attributes
horizon-dark
class Resume {
name string @description("full name")
age int?
@@dynamic
} atom-one-dark
class Resume {
name string @description("full name")
age int?
@@dynamic
} github-dark
class Resume {
name string @description("full name")
age int?
@@dynamic
} dracula
class Resume {
name string @description("full name")
age int?
@@dynamic
} nord
class Resume {
name string @description("full name")
age int?
@@dynamic
} github
class Resume {
name string @description("full name")
age int?
@@dynamic
} 3. Test cases
the test keyword
horizon-dark
test ExtractTest {
functions [Extract]
args {
text #"
Jane Doe, Software Engineer
"#
}
} atom-one-dark
test ExtractTest {
functions [Extract]
args {
text #"
Jane Doe, Software Engineer
"#
}
} github-dark
test ExtractTest {
functions [Extract]
args {
text #"
Jane Doe, Software Engineer
"#
}
} dracula
test ExtractTest {
functions [Extract]
args {
text #"
Jane Doe, Software Engineer
"#
}
} nord
test ExtractTest {
functions [Extract]
args {
text #"
Jane Doe, Software Engineer
"#
}
} github
test ExtractTest {
functions [Extract]
args {
text #"
Jane Doe, Software Engineer
"#
}
}