Skip to main content

text_model_conformance

Function text_model_conformance 

Source
pub async fn text_model_conformance(model: &dyn TextModel)
Expand description

Asserts the TextModel trait contract against a text model whose transport is already scripted to complete text_model_conformance_prompt with TEXT_MODEL_CONFORMANCE_REPLY and the canonical counts in its vendor’s wire shape. The suite makes exactly one complete call — script that one request and no other.

Asserted, each panic naming the rule it caught:

  1. text is the canonical reply, verbatim — no greeting, no chit-chat, no markdown fence around it;
  2. model is non-empty — a completion names what answered, for the log line;
  3. usage is reported on every completion: input_tokens and output_tokens equal the scripted counts;
  4. cached_input_tokens is the scripted cache read, and never exceeds input_tokens — the cached subset of a total cannot be larger than the total;
  5. the prompt carried no schema, so json is None.
ⓘ
// In the adapter's own test, after scripting its transport:
text_model_conformance(&model).await;

§Panics

Panics with the failing rule named when the contract is violated, and when the scripted completion fails.