Skip to contents

Ask a question

Start here. One call reads a document and answers a question, and the answer says what it rests on and whether anything went wrong. See vignette("harnessr").

answer_document()
Answer a question about a document
gr_answer
The result of one reading run
is_not_found()
Did the model report that the document does not contain the answer?
gr_example()
Path to the bundled example document
gr_recipes()
Ready-made recipes
gr_recipe()
Bind an ingestion, segmentation and reading configuration together
gr_compare()
Run several recipes over one document and compare them

Connect to a model

Clients for OpenAI-compatible endpoints, any provider ellmer supports, any function you write, and an offline stand-in for practice and tests. See vignette("harnessr") and the README.

gr_client()
Construct a model client
gr_api_key()
Resolve the API key
gr_ellmer_client()
Read documents through an ellmer chat
gr_backend_client()
Use any function as the model transport
gr_mock_client()
A deterministic offline client for tests, demos and dry runs
gr_call()
Call a model
gr_result
The result of one model call
gr_models()
List every known model
gr_model_info()
Look up a model's capabilities
gr_model_limits()
Context and output limits for a model
gr_register_model()
Register a model (or override a built-in entry)

Get text out of files

Extraction, cleaning and a survey of a folder before anything is spent. See vignette("ingest").

gr_ingest()
Ingest a document into cleaned, provenance-bearing text blocks
gr_ingest_spec()
Describe an ingestion configuration
gr_document
An ingested document
gr_extractors()
List registered extractors
gr_cleaners()
List registered cleaners
gr_clean()
Run the cleaning pipeline over a character vector
gr_inventory()
What is in a folder, before you read any of it

Cut documents into chunks

The segmenters, their settings, and the free statistics for comparing chunkings. See vignette("segment").

gr_segment()
Segment a document into chunks
gr_segment_spec()
Describe a segmentation configuration
gr_segmenters()
List registered segmentation strategies
gr_chunks
A set of document chunks
gr_chunk_stats()
Summary statistics for a chunk set

Read the chunks

The reading strategies, the settings that choose and place chunks, and the check on quoted evidence. See vignette("readers").

gr_read()
Read chunks and answer a question
gr_read_spec()
Describe a reading configuration
gr_readers()
List registered reading strategies
gr_reader_signature()
The traversal signature of a reader
gr_embed()
Embed texts
gr_embedders()
List registered embedding backends
gr_verify_evidence()
Check that quoted evidence really is in the document

Many documents and literature reviews

One question over many documents, and a review from a search export to screened studies, an extraction table, a written review and an audit report, with the screening measured against a hand-screened sample. See vignette("review").

gr_read_many()
Ask one question of many documents
gr_protocol()
Write down what a review is looking for
gr_protocols()
Protocols that ship with the package, and any you have registered
gr_protocol_save() gr_protocol_read()
Save a protocol to a file, and read one back
gr_register_protocol()
Register a protocol
gr_search()
Record how the search was run
gr_records()
Read a search export, and say what the search found
gr_screen()
Decide which documents a review should read
gr_reference()
Draw a sample to screen by hand
gr_calibrate()
Measure the screener against a hand-screened sample
gr_resolve()
Record a person's decision on screened records
`[`(<gr_reference_frame>)
Subsetting a reference frame gives a plain data frame.
gr_fields()
Build an extraction schema
gr_field()
Describe one field of an extraction schema
gr_extract()
Extract a typed schema from many documents
gr_claims()
The claims a table of studies supports
gr_outline()
Derive a review's sections from its claims
gr_outline_pick()
Choose one of the outlines gr_outline() compared
gr_gaps()
What a body of work does not cover
gr_synthesise()
Write a review from an extraction table
gr_flow()
Count what happened to every document
gr_audit_report()
Write the run out as an auditable report

Cost, limits and tracing

Settings and spending limits, token counts and cost estimates, and the trace every run records. See vignette("runs").

gr_options()
Get or set package options
hr_governor()
Limits on what a run may send
gr_estimate_cost()
Estimate the USD cost of a set of calls
gr_count_tokens()
Count tokens in text
gr_tokenizer()
The active tokenizer
gr_set_tokenizer()
Register or inspect the active tokenizer
gr_truncate_tokens()
Truncate text to at most n tokens
gr_budget()
Compute a usable input-token budget for one model call
gr_trace() as.data.frame(<gr_trace>)
Create a run trace
gr_trace_summary()
Summarise a trace
gr_trace_cost()
What a run actually cost
gr_trace_save()
Save a trace to a file
as_json()
Serialise an object to JSON

Caching and replaying runs

Paying for a request once, and replaying a recorded run without a model. See vignette("runs").

gr_cache()
A response cache
gr_cache_client()
Attach a cache to a client
gr_cache_stats()
Cache statistics
gr_cache_clear()
Delete every entry in a cache
gr_flush_caches()
Clear the session's document and embedding caches
gr_replay_client()
A client that answers from a recorded run

Extending harnessr

Every axis is a registry, and an addition is used exactly like a built-in. See vignette("extending").

gr_register_extractor()
Register a document extractor
gr_register_cleaner()
Register a cleaning step
gr_register_segmenter()
Register a segmentation strategy
gr_register_reader()
Register a reading strategy
gr_register_embedder()
Register an embedding backend
new_chunks()
Build a gr_chunks, the object every segmenter must return
new_answer()
Build a gr_answer, the object every reader must return
hr_cost()
What one run of a module can cost
hr_schema()
Collect parameters into a schema
hr_param()
Declare one parameter of a module or spec
hr_validate()
Validate and resolve settings against a schema
hr_check_module()
Check a module against a set of rules
gr_check_reader()
Check a reader against the reader contract
gr_check_segmenter()
Check a segmenter against the segmenter contract

Superseded

The entry points of the first version, and the old name of gr_example(). They still work and warn once; new code should use answer_document(), gr_ingest(), gr_segment() and gr_example(). The README’s “Migrating from v1” section maps each one.

answer_question()
Deprecated: answer a question using v1 mode names
parse_text()
Deprecated: parse a document into text chunks
gpt_read_chunked()
Deprecated: chunk-by-chunk reading
gpt_read_hierarchical()
Deprecated: hierarchical reading
gpt_read_multipass()
Deprecated: multi-pass reading
gpt_read_retrieval()
Deprecated: evidence-extraction reading
readgpt_example()
Deprecated: path to the bundled example document