Expand description
Pre-built helpers for testing code that uses llm-core types.
Available when the test-utils feature is enabled, allowing
downstream crates to reuse these utilities in their own test
suites. Also compiled during #[cfg(test)] for this crate’s
own tests. Provides sample responses, message shorthands, stream
collectors, and a quick MockProvider factory.
Functions§
- assistant_
msg - Shorthand for
ChatMessage::assistant. - collect_
stream - Collect stream events, panicking on any error.
Use
collect_stream_resultswhen testing error scenarios. - collect_
stream_ results - Collect stream events, returning results including errors.
- mock_
for - Creates a
MockProviderwith the given name, model, andCapability::Tools. - sample_
response - Builds a
ChatResponsewith a single text block and default usage. - sample_
tool_ response - Builds a
ChatResponsecontaining the given tool calls. - sample_
usage - Returns a
Usagewith 100 input / 50 output tokens. - system_
msg - Shorthand for
ChatMessage::system. - tool_
result_ msg - Shorthand for
ChatMessage::tool_result. - user_
msg - Shorthand for
ChatMessage::user.