pub fn build_enforced_tool_request(
messages: &[Message],
tool: &ToolDefinition,
provider: Provider,
) -> ValueExpand description
Build a request that enforces a specific tool call (like pydantic AI / luagent pattern)
This is the recommended approach for structured outputs - it guarantees the LLM will call the specified tool, ensuring you always get back your structured data.
§Example
ⓘ
use struct_llm::{build_enforced_tool_request, Provider, StructuredOutput};
let tool = MyOutput::tool_definition();
let request = build_enforced_tool_request(
&messages,
&tool,
Provider::OpenAI
);
// The LLM will be forced to call MyOutput's tool