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.

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

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.

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

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

gr_read_many()
Ask one question of many documents

Systematic and literature reviews

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.

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_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_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, tokens and tracing

gr_options()
Get or set package options
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

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_replay_client()
A client that answers from a recorded run

Extending readgpt

Every axis is a registry. An addition is used exactly like a built-in.

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

Superseded

The entry points of the first version. They still work and warn once; new code should use answer_document(), gr_ingest() and gr_segment().

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