Reads the bundled example document (gr_example()) with one registered
reader, through an offline client, and reports which rules of the reader
contract it breaks. Nothing is refused: a reader that fails a rule stays
registered and runs as before. Use it on a reader of your own after
gr_register_reader().
Arguments
- reader
A registered reader's name; see
gr_readers().- client
A
gr_clientto read with.NULL(the default) uses agr_mock_client()whose reply to a request with a JSON schema is an object of that schema's shape, and a fixed sentence otherwise.
Value
An hr_conformance data frame; see hr_check_module().
Details
The document is cut with list(method = "paragraph", max_tokens = 150) and
read on a fresh gr_trace(). Readers that need more than a question are
given what they need: extract one field, screen one inclusion
criterion, and ensemble the members "stuff" and "retrieve".
Rules
is_function,runsThe reader's
fnis a function, andgr_read()with it finishes without an error.answer_classIt returns a gr_answer.
answer_fieldsThe answer has every field gr_answer documents for
gr_read():answer,reader,question,chunks_used,partial,notes,trace,warningsandsignature, withpartialoneTRUEorFALSE.answer_textansweris a single string, notNA.evidenceevidenceisNULL, or a data frame with achunk_idcolumn whose ids are all chunks of the input.NAis allowed, for a span placed in no chunk.chunks_usedEvery id in
chunks_usedis a chunk of the input.calls_declaredThe label of every model call in the trace is covered by a stem the reader declared in
calls, by the rule aneffortmap is checked with (a stem, a part of one up to a dot, or a label under one). Forensemble, its members' stems count too.calls_within_costThe requests the run made, embeddings included, are no more than the worst case its
costfunction gave for this input, as the pre-flight check recorded it.NAfor a reader registered withoutcost.
See also
hr_check_module(), gr_check_segmenter(), gr_register_reader()
Other reading functions:
gr_answer,
gr_read(),
gr_read_spec(),
gr_reader_signature(),
gr_readers(),
gr_register_reader(),
is_not_found(),
new_answer()
Examples
gr_check_reader("stuff")
#> Using cached ingestion for this document + settings.
#> Segmenting with 'paragraph' (cap 150 tokens, overlap 0).
#> Reading with 'stuff' (all|1|none) over 5 chunk(s).
#> <hr_conformance> reader 'stuff', contract 0.1
#> passes all 9 rules
#> ok is_function
#> ok runs
#> ok answer_class
#> ok answer_fields
#> ok answer_text
#> ok evidence
#> ok chunks_used
#> ok calls_declared: 1 call(s), all under declared stems
#> ok calls_within_cost: 1 request(s) made, at most 1 expected
# A reader whose calls carry a label it did not declare.
gr_register_reader("loose", signature = "one|1|none", calls = "loose.answer",
fn = function(chunks, question, client, spec, trace) {
res <- gr_call(client, list(list(role = "user", content = question)),
model = spec$model, trace = trace, label = "other.answer")
new_answer(res$text, "loose", question, integer(0), trace)
})
gr_check_reader("loose")
#> Using cached ingestion for this document + settings.
#> Segmenting with 'paragraph' (cap 150 tokens, overlap 0).
#> Reading with 'loose' (one|1|none) over 5 chunk(s).
#> <hr_conformance> reader 'loose', contract 0.1
#> fails 1 of 9 rules
#> FAIL calls_declared: label(s) 'other.answer' not under the declared stems loose.answer
#> skip calls_within_cost: not checked: no cost function declared
#> ok is_function
#> ok runs
#> ok answer_class
#> ok answer_fields
#> ok answer_text
#> ok evidence: no evidence
#> ok chunks_used