Document search
Answer a question over local documents by planning subquestions, retrieving in parallel, then validating claim citations and exact quotes. Documents and vectors are temporary, scoped to the run and removed afterward.
Capabilities
| Capability | Kind | Signature | Module | Summary |
|---|---|---|---|---|
plan_query | traversal | (question: str) -> dict | examples/python/document_search/main.py | |
query_document | traversal | (file_path: str, question: str) -> dict | examples/python/document_search/main.py | |
retrieve | skill | (question: str, top_k: int = 4) -> list[dict] | examples/python/document_search/main.py |
Commands
EXAMPLE_MODE=fixture python -m atfgraph.worker --module examples.python.document_search.main:app
atfg install ./examples/python/document_search
atfg run document_search
atfg server start
atfg traverse document_search.query_document --in '{"file_path": "sample_document.txt", "question": "Summarize the document and cite the evidence."}'
python -m examples.python.document_search.call
Files
examples/python/document_search/README.mdexamples/python/document_search/__init__.pyexamples/python/document_search/agentnode.yamlexamples/python/document_search/call.pyexamples/python/document_search/main.pyexamples/python/document_search/node.pyexamples/python/document_search/requirements.txtexamples/python/document_search/sample_document.txtexamples/python/document_search/support.py
README
Answer a question over local documents by planning subquestions, retrieving in parallel, then validating claim citations and exact quotes. Documents and vectors are temporary, scoped to the run and removed afterward.
Run locally
With the SDK installed, run from the repository root:
atfg server start
EXAMPLE_MODE=fixture python -m atfgraph.worker --module examples.python.document_search.main:app
# In a second terminal:
python -m examples.python.document_search.call
Or install the example as a managed local node:
atfg install ./examples/python/document_search
atfg run document_search
The node.py entrypoint also works after copying the folder outside the repository. The default server is http://127.0.0.1:18880; use /ui/ to inspect child calls and results.
Call with the CLI
atfg traverse document_search.query_document --in '{"file_path": "sample_document.txt", "question": "Summarize the document and cite the evidence."}'
Providers
Fixture mode is the default. It uses deterministic data and token-hash embeddings without external provider calls. Scores illustrate the flow rather than model quality.
To use real providers, set EXAMPLE_MODE=live and configure the model URL/name/key plus the full embedding endpoint URL, model and optional key through ATFGRAPH_MODEL_* and ATFGRAPH_EMBEDDING_*. Start the worker after setting them. Configuration failures do not fall back to fixture answers.
EXAMPLE_DOCUMENT_ROOT bounds local reads and defaults to this folder. Accepted files are text, Markdown and reStructuredText, at most 1 MB each and 100 files per folder ingestion. Treat document text as untrusted input. Valid citation IDs and exact quotes do not establish that a generated conclusion is correct.
Python client
from atfgraph import Client
async with Client("http://127.0.0.1:18880") as client:
result = await client.traverse(
"document_search.query_document",
{'file_path': 'sample_document.txt', 'question': 'Summarize the document and cite the evidence.'},
timeout=300,
)
print(result)