Superseded by gr_read() with reader = "hierarchical". The new reader
recurses until the summaries fit the context window; v1 summarised exactly
once and overflowed past roughly 32 chunks.
Arguments
- chunks
Character vector of chunks, or a
gr_chunks.- question
The question.
- client
A
gr_client.- return_json
Return the whole answer object, including its trace, as JSON.
- ...
Passed to
gr_read_spec().
Value
A single string when return_json is FALSE; otherwise a
json-classed string holding the answer, its notes and the full trace.
See also
gr_read() and reader = "hierarchical", gr_read_spec() for
fan_in and max_levels, gr_readers()
Other v1 compatibility:
answer_question(),
gpt_read_chunked(),
gpt_read_multipass(),
gpt_read_retrieval(),
parse_text()
Examples
cl <- gr_mock_client(function(m, p) "45.2 million dollars")
chunks <- suppressWarnings(parse_text(readgpt_example(), chunk_token_limit = 200))
#> Using cached ingestion for this document + settings.
#> Segmenting with 'paragraph' (cap 200 tokens, overlap 0).
suppressWarnings(gpt_read_hierarchical(chunks, "What was revenue?", client = cl))
#> Using cached ingestion for this document + settings.
#> Reading with 'hierarchical' (all|N+tree+1|tree) over 4 chunk(s).
#> [1] "45.2 million dollars"
# The modern equivalent.
ch <- gr_segment(readgpt_example(), list(method = "paragraph", max_tokens = 200))
#> Using cached ingestion for this document + settings.
#> Segmenting with 'paragraph' (cap 200 tokens, overlap 0).
gr_read(ch, "What was revenue?", gr_mock_client(function(m, p) "45.2 million dollars"),
"hierarchical")$reader
#> Reading with 'hierarchical' (all|N+tree+1|tree) over 4 chunk(s).
#> [1] "hierarchical"