sam_vultron
12/02/2025, 8:24 PMrequired where we want to force the LLM to call a tool. We also only want to create one chatfunction for these different configurations. What is the best way to do this?greg (BAML)
12/02/2025, 8:57 PMsam_vultron
12/02/2025, 9:34 PMclass tool_1{
a: int
b: int
}
function MyFunc(input:str) -> string | tool_1
This should also work if we set to required mode, where we would have:
function MyFunc(input:str) -> tool_1
or none mode:
function MyFunc(input:str) -> stringsam_vultron
12/02/2025, 9:39 PMgreg (BAML)
12/03/2025, 12:43 AMtype Tool = tool_1 | tool_2 | tool_3
function MyFunc(input: string) -> Tool[] {
client WillBeOverriddenByClientRegistry
prompt #"Choose tools to satisfy the query
{{ input }}.
(( ctx.output_format }}
"#
}greg (BAML)
12/03/2025, 12:44 AMhenry_75477
12/03/2025, 12:51 AMtype Tool = tool_1 | tool_2 | tool_3 | stringgreg (BAML)
12/03/2025, 1:11 AMclass Response {
tool_call: Tool_1 | Tool_2 | Tool_3
message: string?
}
This type captures all those possibilities.
Also just making sure, you're using the openai-responses client type?greg (BAML)
12/03/2025, 1:14 AMtype Tool = tool_1 | tool_2 | tool_3 | string as you said might be the right thing here!greg (BAML)
12/03/2025, 1:14 AMhenry_75477
12/03/2025, 7:53 PM