biblicus 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. {biblicus-0.4.0/src/biblicus.egg-info → biblicus-0.5.0}/PKG-INFO +247 -102
  2. {biblicus-0.4.0 → biblicus-0.5.0}/README.md +246 -101
  3. {biblicus-0.4.0 → biblicus-0.5.0}/docs/ARCHITECTURE.md +1 -0
  4. biblicus-0.5.0/docs/CONTEXT_PACK.md +61 -0
  5. {biblicus-0.4.0 → biblicus-0.5.0}/docs/FEATURE_INDEX.md +20 -0
  6. biblicus-0.5.0/docs/ROADMAP.md +81 -0
  7. {biblicus-0.4.0 → biblicus-0.5.0}/docs/api.rst +4 -0
  8. {biblicus-0.4.0 → biblicus-0.5.0}/docs/index.rst +1 -0
  9. biblicus-0.5.0/features/context_pack.feature +42 -0
  10. biblicus-0.5.0/features/context_pack_cli.feature +29 -0
  11. biblicus-0.5.0/features/evidence_processing.feature +25 -0
  12. biblicus-0.5.0/features/query_processing.feature +27 -0
  13. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/cli_steps.py +102 -0
  14. biblicus-0.5.0/features/steps/context_pack_steps.py +115 -0
  15. biblicus-0.5.0/features/steps/evidence_processing_steps.py +47 -0
  16. biblicus-0.5.0/features/token_budget.feature +37 -0
  17. {biblicus-0.4.0 → biblicus-0.5.0}/pyproject.toml +1 -1
  18. biblicus-0.5.0/scripts/readme_end_to_end_demo.py +81 -0
  19. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/__init__.py +1 -1
  20. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/cli.py +90 -1
  21. biblicus-0.5.0/src/biblicus/context.py +183 -0
  22. biblicus-0.5.0/src/biblicus/evidence_processing.py +201 -0
  23. {biblicus-0.4.0 → biblicus-0.5.0/src/biblicus.egg-info}/PKG-INFO +247 -102
  24. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus.egg-info/SOURCES.txt +11 -0
  25. biblicus-0.4.0/docs/ROADMAP.md +0 -200
  26. {biblicus-0.4.0 → biblicus-0.5.0}/LICENSE +0 -0
  27. {biblicus-0.4.0 → biblicus-0.5.0}/MANIFEST.in +0 -0
  28. {biblicus-0.4.0 → biblicus-0.5.0}/THIRD_PARTY_NOTICES.md +0 -0
  29. {biblicus-0.4.0 → biblicus-0.5.0}/datasets/wikipedia_mini.json +0 -0
  30. {biblicus-0.4.0 → biblicus-0.5.0}/docs/BACKENDS.md +0 -0
  31. {biblicus-0.4.0 → biblicus-0.5.0}/docs/CORPUS.md +0 -0
  32. {biblicus-0.4.0 → biblicus-0.5.0}/docs/CORPUS_DESIGN.md +0 -0
  33. {biblicus-0.4.0 → biblicus-0.5.0}/docs/DEMOS.md +0 -0
  34. {biblicus-0.4.0 → biblicus-0.5.0}/docs/EXTRACTION.md +0 -0
  35. {biblicus-0.4.0 → biblicus-0.5.0}/docs/TESTING.md +0 -0
  36. {biblicus-0.4.0 → biblicus-0.5.0}/docs/USER_CONFIGURATION.md +0 -0
  37. {biblicus-0.4.0 → biblicus-0.5.0}/docs/conf.py +0 -0
  38. {biblicus-0.4.0 → biblicus-0.5.0}/features/backend_validation.feature +0 -0
  39. {biblicus-0.4.0 → biblicus-0.5.0}/features/biblicus_corpus.feature +0 -0
  40. {biblicus-0.4.0 → biblicus-0.5.0}/features/cli_entrypoint.feature +0 -0
  41. {biblicus-0.4.0 → biblicus-0.5.0}/features/cli_parsing.feature +0 -0
  42. {biblicus-0.4.0 → biblicus-0.5.0}/features/content_sniffing.feature +0 -0
  43. {biblicus-0.4.0 → biblicus-0.5.0}/features/corpus_edge_cases.feature +0 -0
  44. {biblicus-0.4.0 → biblicus-0.5.0}/features/corpus_identity.feature +0 -0
  45. {biblicus-0.4.0 → biblicus-0.5.0}/features/corpus_purge.feature +0 -0
  46. {biblicus-0.4.0 → biblicus-0.5.0}/features/crawl.feature +0 -0
  47. {biblicus-0.4.0 → biblicus-0.5.0}/features/environment.py +0 -0
  48. {biblicus-0.4.0 → biblicus-0.5.0}/features/error_cases.feature +0 -0
  49. {biblicus-0.4.0 → biblicus-0.5.0}/features/evaluation.feature +0 -0
  50. {biblicus-0.4.0 → biblicus-0.5.0}/features/extraction_error_handling.feature +0 -0
  51. {biblicus-0.4.0 → biblicus-0.5.0}/features/extraction_run_lifecycle.feature +0 -0
  52. {biblicus-0.4.0 → biblicus-0.5.0}/features/extraction_selection.feature +0 -0
  53. {biblicus-0.4.0 → biblicus-0.5.0}/features/extraction_selection_longest.feature +0 -0
  54. {biblicus-0.4.0 → biblicus-0.5.0}/features/extractor_pipeline.feature +0 -0
  55. {biblicus-0.4.0 → biblicus-0.5.0}/features/extractor_validation.feature +0 -0
  56. {biblicus-0.4.0 → biblicus-0.5.0}/features/frontmatter.feature +0 -0
  57. {biblicus-0.4.0 → biblicus-0.5.0}/features/hook_config_validation.feature +0 -0
  58. {biblicus-0.4.0 → biblicus-0.5.0}/features/hook_error_handling.feature +0 -0
  59. {biblicus-0.4.0 → biblicus-0.5.0}/features/import_tree.feature +0 -0
  60. {biblicus-0.4.0 → biblicus-0.5.0}/features/ingest_sources.feature +0 -0
  61. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_audio_samples.feature +0 -0
  62. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_image_samples.feature +0 -0
  63. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_mixed_corpus.feature +0 -0
  64. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_mixed_extraction.feature +0 -0
  65. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_ocr_image_extraction.feature +0 -0
  66. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_pdf_retrieval.feature +0 -0
  67. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_pdf_samples.feature +0 -0
  68. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_unstructured_extraction.feature +0 -0
  69. {biblicus-0.4.0 → biblicus-0.5.0}/features/integration_wikipedia.feature +0 -0
  70. {biblicus-0.4.0 → biblicus-0.5.0}/features/lifecycle_hooks.feature +0 -0
  71. {biblicus-0.4.0 → biblicus-0.5.0}/features/model_validation.feature +0 -0
  72. {biblicus-0.4.0 → biblicus-0.5.0}/features/ocr_extractor.feature +0 -0
  73. {biblicus-0.4.0 → biblicus-0.5.0}/features/pdf_text_extraction.feature +0 -0
  74. {biblicus-0.4.0 → biblicus-0.5.0}/features/python_api.feature +0 -0
  75. {biblicus-0.4.0 → biblicus-0.5.0}/features/python_hook_logging.feature +0 -0
  76. {biblicus-0.4.0 → biblicus-0.5.0}/features/retrieval_budget.feature +0 -0
  77. {biblicus-0.4.0 → biblicus-0.5.0}/features/retrieval_scan.feature +0 -0
  78. {biblicus-0.4.0 → biblicus-0.5.0}/features/retrieval_sqlite_full_text_search.feature +0 -0
  79. {biblicus-0.4.0 → biblicus-0.5.0}/features/retrieval_uses_extraction_run.feature +0 -0
  80. {biblicus-0.4.0 → biblicus-0.5.0}/features/retrieval_utilities.feature +0 -0
  81. {biblicus-0.4.0 → biblicus-0.5.0}/features/source_loading.feature +0 -0
  82. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/backend_steps.py +0 -0
  83. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/cli_parsing_steps.py +0 -0
  84. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/crawl_steps.py +0 -0
  85. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/extraction_run_lifecycle_steps.py +0 -0
  86. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/extraction_steps.py +0 -0
  87. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/extractor_steps.py +0 -0
  88. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/frontmatter_steps.py +0 -0
  89. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/model_steps.py +0 -0
  90. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/openai_steps.py +0 -0
  91. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/pdf_steps.py +0 -0
  92. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/python_api_steps.py +0 -0
  93. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/rapidocr_steps.py +0 -0
  94. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/retrieval_steps.py +0 -0
  95. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/stt_steps.py +0 -0
  96. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/unstructured_steps.py +0 -0
  97. {biblicus-0.4.0 → biblicus-0.5.0}/features/steps/user_config_steps.py +0 -0
  98. {biblicus-0.4.0 → biblicus-0.5.0}/features/streaming_ingest.feature +0 -0
  99. {biblicus-0.4.0 → biblicus-0.5.0}/features/stt_extractor.feature +0 -0
  100. {biblicus-0.4.0 → biblicus-0.5.0}/features/text_extraction_runs.feature +0 -0
  101. {biblicus-0.4.0 → biblicus-0.5.0}/features/unstructured_extractor.feature +0 -0
  102. {biblicus-0.4.0 → biblicus-0.5.0}/features/user_config.feature +0 -0
  103. {biblicus-0.4.0 → biblicus-0.5.0}/scripts/download_audio_samples.py +0 -0
  104. {biblicus-0.4.0 → biblicus-0.5.0}/scripts/download_image_samples.py +0 -0
  105. {biblicus-0.4.0 → biblicus-0.5.0}/scripts/download_mixed_samples.py +0 -0
  106. {biblicus-0.4.0 → biblicus-0.5.0}/scripts/download_pdf_samples.py +0 -0
  107. {biblicus-0.4.0 → biblicus-0.5.0}/scripts/download_wikipedia.py +0 -0
  108. {biblicus-0.4.0 → biblicus-0.5.0}/scripts/test.py +0 -0
  109. {biblicus-0.4.0 → biblicus-0.5.0}/setup.cfg +0 -0
  110. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/__main__.py +0 -0
  111. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/_vendor/dotyaml/__init__.py +0 -0
  112. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/_vendor/dotyaml/interpolation.py +0 -0
  113. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/_vendor/dotyaml/loader.py +0 -0
  114. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/_vendor/dotyaml/transformer.py +0 -0
  115. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/backends/__init__.py +0 -0
  116. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/backends/base.py +0 -0
  117. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/backends/scan.py +0 -0
  118. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/backends/sqlite_full_text_search.py +0 -0
  119. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/constants.py +0 -0
  120. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/corpus.py +0 -0
  121. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/crawl.py +0 -0
  122. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/errors.py +0 -0
  123. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/evaluation.py +0 -0
  124. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extraction.py +0 -0
  125. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/__init__.py +0 -0
  126. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/base.py +0 -0
  127. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/metadata_text.py +0 -0
  128. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/openai_stt.py +0 -0
  129. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/pass_through_text.py +0 -0
  130. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/pdf_text.py +0 -0
  131. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/pipeline.py +0 -0
  132. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/rapidocr_text.py +0 -0
  133. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/select_longest_text.py +0 -0
  134. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/select_text.py +0 -0
  135. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/extractors/unstructured_text.py +0 -0
  136. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/frontmatter.py +0 -0
  137. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/hook_logging.py +0 -0
  138. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/hook_manager.py +0 -0
  139. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/hooks.py +0 -0
  140. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/ignore.py +0 -0
  141. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/models.py +0 -0
  142. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/retrieval.py +0 -0
  143. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/sources.py +0 -0
  144. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/time.py +0 -0
  145. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/uris.py +0 -0
  146. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus/user_config.py +0 -0
  147. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus.egg-info/dependency_links.txt +0 -0
  148. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus.egg-info/entry_points.txt +0 -0
  149. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus.egg-info/requires.txt +0 -0
  150. {biblicus-0.4.0 → biblicus-0.5.0}/src/biblicus.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: biblicus
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Command line interface and Python library for corpus ingestion, retrieval, and evaluation.
5
5
  License: MIT
6
6
  Requires-Python: >=3.9
@@ -41,11 +41,11 @@ The first practical problem is not retrieval. It is collection and care. You nee
41
41
 
42
42
  This library gives you a corpus, which is a normal folder on disk. It stores each ingested item as a file, with optional metadata stored next to it. You can open and inspect the raw files directly. Any derived catalog or index can be rebuilt from the raw corpus.
43
43
 
44
- It can be used alongside LangChain, Tactus, Pydantic AI, or the agent development kit. Use it from Python or from the command line interface.
44
+ It can be used alongside LangGraph, Tactus, Pydantic AI, any agent framework, or your own setup. Use it from Python or from the command line interface.
45
45
 
46
46
  See [retrieval augmented generation overview] for a short introduction to the idea.
47
47
 
48
- ## A beginner friendly mental model
48
+ ## A simple mental model
49
49
 
50
50
  Think in three stages.
51
51
 
@@ -63,94 +63,30 @@ If you learn a few project words, the rest of the system becomes predictable.
63
63
  - Run is a recorded retrieval build for a corpus.
64
64
  - Evidence is what retrieval returns, with identifiers and source information.
65
65
 
66
- ## Diagram
66
+ ## Where it fits in an assistant
67
67
 
68
- This diagram shows how a corpus becomes evidence for an assistant.
69
- Extraction is introduced here as a separate stage so you can swap extraction approaches without changing the raw corpus.
70
- The legend shows what the block styles mean.
71
- Your code is where you decide how to turn evidence into context and how to call a model.
68
+ Biblicus does not answer user questions. It is not a language model. It helps your assistant answer them by retrieving relevant material and returning it as structured evidence. Your code decides how to turn evidence into a context pack for the model call, which is then passed to a model you choose.
72
69
 
73
- ```mermaid
74
- %%{init: {"flowchart": {"useMaxWidth": true, "nodeSpacing": 18, "rankSpacing": 22}}}%%
75
- flowchart LR
76
- subgraph Legend[Legend]
77
- direction LR
78
- LegendArtifact[Stored artifact or evidence]
79
- LegendStep[Step]
80
- LegendArtifact --- LegendStep
81
- end
82
-
83
- subgraph Main[" "]
84
- direction TB
70
+ In a coding assistant, retrieval is often triggered by what the user is doing right now. For example: you are about to propose a user interface change, so you retrieve the user's stated preferences, then you include that as context for the model call.
85
71
 
86
- subgraph StableCore[Stable core]
87
- direction TB
88
- Source[Source items] --> Ingest[Ingest]
89
- Ingest --> Raw[Raw item files]
90
- Raw --> Catalog[Catalog file]
91
- end
92
-
93
- subgraph PluggableExtractionPipeline[Pluggable: extraction pipeline]
94
- direction TB
95
- Catalog --> Extract[Extract pipeline]
96
- Extract --> ExtractedText[Extracted text artifacts]
97
- ExtractedText --> ExtractionRun[Extraction run manifest]
98
- end
99
-
100
- subgraph PluggableRetrievalBackend[Pluggable: retrieval backend]
101
- direction LR
102
-
103
- subgraph BackendIngestionIndexing[Ingestion and indexing]
104
- direction TB
105
- ExtractionRun --> Build[Build run]
106
- Build --> BackendIndex[Backend index]
107
- BackendIndex --> Run[Run manifest]
108
- end
72
+ This diagram shows two sequential Biblicus calls. They are shown separately to make the boundaries explicit: retrieval returns evidence, and context pack building consumes evidence.
109
73
 
110
- subgraph BackendRetrievalGeneration[Retrieval and generation]
111
- direction TB
112
- Run --> Query[Query]
113
- Query --> Evidence[Evidence]
114
- end
115
- end
116
-
117
- Evidence --> Context
118
-
119
- subgraph YourCode[Your code]
120
- direction TB
121
- Context[Assistant context] --> Model[Large language model call]
122
- Model --> Answer[Answer]
123
- end
124
-
125
- style StableCore fill:#ffffff,stroke:#8e24aa,stroke-width:2px,color:#111111
126
- style PluggableExtractionPipeline fill:#ffffff,stroke:#5e35b1,stroke-dasharray:6 3,stroke-width:2px,color:#111111
127
- style PluggableRetrievalBackend fill:#ffffff,stroke:#1e88e5,stroke-dasharray:6 3,stroke-width:2px,color:#111111
128
- style YourCode fill:#ffffff,stroke:#d81b60,stroke-width:2px,color:#111111
129
- style BackendIngestionIndexing fill:#ffffff,stroke:#cfd8dc,color:#111111
130
- style BackendRetrievalGeneration fill:#ffffff,stroke:#cfd8dc,color:#111111
131
-
132
- style Raw fill:#f3e5f5,stroke:#8e24aa,color:#111111
133
- style Catalog fill:#f3e5f5,stroke:#8e24aa,color:#111111
134
- style ExtractedText fill:#f3e5f5,stroke:#8e24aa,color:#111111
135
- style ExtractionRun fill:#f3e5f5,stroke:#8e24aa,color:#111111
136
- style BackendIndex fill:#f3e5f5,stroke:#8e24aa,color:#111111
137
- style Run fill:#f3e5f5,stroke:#8e24aa,color:#111111
138
- style Evidence fill:#f3e5f5,stroke:#8e24aa,color:#111111
139
- style Context fill:#f3e5f5,stroke:#8e24aa,color:#111111
140
- style Answer fill:#f3e5f5,stroke:#8e24aa,color:#111111
141
- style Source fill:#f3e5f5,stroke:#8e24aa,color:#111111
142
-
143
- style Ingest fill:#eceff1,stroke:#90a4ae,color:#111111
144
- style Extract fill:#eceff1,stroke:#90a4ae,color:#111111
145
- style Build fill:#eceff1,stroke:#90a4ae,color:#111111
146
- style Query fill:#eceff1,stroke:#90a4ae,color:#111111
147
- style Model fill:#eceff1,stroke:#90a4ae,color:#111111
148
- end
149
-
150
- style Legend fill:#ffffff,stroke:#ffffff,color:#111111
151
- style Main fill:#ffffff,stroke:#ffffff,color:#111111
152
- style LegendArtifact fill:#f3e5f5,stroke:#8e24aa,color:#111111
153
- style LegendStep fill:#eceff1,stroke:#90a4ae,color:#111111
74
+ ```mermaid
75
+ %%{init: {"theme": "base", "themeVariables": {"primaryColor": "#f3e5f5", "primaryTextColor": "#111111", "primaryBorderColor": "#8e24aa", "lineColor": "#90a4ae", "secondaryColor": "#eceff1", "tertiaryColor": "#ffffff", "noteBkgColor": "#ffffff", "noteTextColor": "#111111", "actorBkg": "#f3e5f5", "actorBorder": "#8e24aa", "actorTextColor": "#111111"}}}%%
76
+ sequenceDiagram
77
+ participant User
78
+ participant App as Your assistant code
79
+ participant Bib as Biblicus
80
+ participant LLM as Large language model
81
+
82
+ User->>App: request
83
+ App->>Bib: query retrieval
84
+ Bib-->>App: retrieval result evidence JSON
85
+ App->>Bib: build context pack from evidence
86
+ Bib-->>App: context pack text
87
+ App->>LLM: context pack plus prompt
88
+ LLM-->>App: response draft
89
+ App-->>User: response
154
90
  ```
155
91
 
156
92
  ## Practical value
@@ -217,6 +153,216 @@ biblicus crawl --corpus corpora/example \\
217
153
  --tag crawled
218
154
  ```
219
155
 
156
+ ## End-to-end example: evidence to assistant context
157
+
158
+ The command-line interface returns JavaScript Object Notation by default. This makes it easy to use Biblicus in scripts and to treat retrieval as a deterministic, testable step.
159
+
160
+ Start with a few short “memories” from a chat system. Each memory is stored as a normal item in the corpus.
161
+
162
+ ```python
163
+ from biblicus.backends import get_backend
164
+ from biblicus.context import ContextPackPolicy, TokenBudget, build_context_pack, fit_context_pack_to_token_budget
165
+ from biblicus.corpus import Corpus
166
+ from biblicus.models import QueryBudget
167
+
168
+
169
+ corpus = Corpus.init("corpora/story")
170
+
171
+ notes = [
172
+ ("User name", "The user's name is Tactus Maximus."),
173
+ ("Button style preference", "Primary button style preference: the user's favorite color is magenta."),
174
+ ("Style preference", "The user prefers concise answers."),
175
+ ("Language preference", "The user dislikes idioms and abbreviations."),
176
+ ("Engineering preference", "The user likes code that is over-documented and behavior-driven."),
177
+ ]
178
+ for note_title, note_text in notes:
179
+ corpus.ingest_note(note_text, title=note_title, tags=["memory"])
180
+
181
+ backend = get_backend("scan")
182
+ run = backend.build_run(corpus, recipe_name="Story demo", config={})
183
+ budget = QueryBudget(max_total_items=5, max_total_characters=2000, max_items_per_source=None)
184
+ result = backend.query(
185
+ corpus,
186
+ run=run,
187
+ query_text="Primary button style preference",
188
+ budget=budget,
189
+ )
190
+
191
+ policy = ContextPackPolicy(join_with="\n\n")
192
+ context_pack = build_context_pack(result, policy=policy)
193
+ context_pack = fit_context_pack_to_token_budget(
194
+ context_pack,
195
+ policy=policy,
196
+ token_budget=TokenBudget(max_tokens=60),
197
+ )
198
+ print(context_pack.text)
199
+ ```
200
+
201
+ If you want a runnable version of this story, use the script at `scripts/readme_end_to_end_demo.py`.
202
+
203
+ If you prefer the command-line interface, here is the same flow in compressed form:
204
+
205
+ ```
206
+ biblicus init corpora/story
207
+ biblicus ingest --corpus corpora/story --stdin --title "User name" --tag memory <<< "The user's name is Tactus Maximus."
208
+ biblicus ingest --corpus corpora/story --stdin --title "Button style preference" --tag memory <<< "Primary button style preference: the user's favorite color is magenta."
209
+ biblicus ingest --corpus corpora/story --stdin --title "Style preference" --tag memory <<< "The user prefers concise answers."
210
+ biblicus ingest --corpus corpora/story --stdin --title "Language preference" --tag memory <<< "The user dislikes idioms and abbreviations."
211
+ biblicus ingest --corpus corpora/story --stdin --title "Engineering preference" --tag memory <<< "The user likes code that is over-documented and behavior-driven."
212
+ biblicus build --corpus corpora/story --backend scan
213
+ biblicus query --corpus corpora/story --query "Primary button style preference"
214
+ ```
215
+
216
+ Example output:
217
+
218
+ ```json
219
+ {
220
+ "query_text": "Primary button style preference",
221
+ "budget": {
222
+ "max_total_items": 5,
223
+ "max_total_characters": 2000,
224
+ "max_items_per_source": null
225
+ },
226
+ "run_id": "RUN_ID",
227
+ "recipe_id": "RECIPE_ID",
228
+ "backend_id": "scan",
229
+ "generated_at": "2026-01-29T00:00:00.000000Z",
230
+ "evidence": [
231
+ {
232
+ "item_id": "ITEM_ID",
233
+ "source_uri": "text",
234
+ "media_type": "text/markdown",
235
+ "score": 1.0,
236
+ "rank": 1,
237
+ "text": "Primary button style preference: the user's favorite color is magenta.",
238
+ "content_ref": null,
239
+ "span_start": null,
240
+ "span_end": null,
241
+ "stage": "scan",
242
+ "recipe_id": "RECIPE_ID",
243
+ "run_id": "RUN_ID",
244
+ "hash": null
245
+ }
246
+ ],
247
+ "stats": {}
248
+ }
249
+ ```
250
+
251
+ Evidence is the output contract. Your code decides how to convert evidence into assistant context.
252
+
253
+ ### Turn evidence into a context pack
254
+
255
+ A context pack is a readable text block you send to a model. There is no single correct format. Treat it as a policy surface you can iterate on.
256
+
257
+ Here is a minimal example that builds a context pack from evidence:
258
+
259
+ ```python
260
+ from biblicus.context import ContextPackPolicy, build_context_pack
261
+
262
+
263
+ policy = ContextPackPolicy(
264
+ join_with="\n\n",
265
+ )
266
+ context_pack = build_context_pack(result, policy=policy)
267
+ print(context_pack.text)
268
+ ```
269
+
270
+ Example context pack output:
271
+
272
+ ```text
273
+ Primary button style preference: the user's favorite color is magenta.
274
+ ```
275
+
276
+ You can also build a context pack from the command-line interface by piping the retrieval result:
277
+
278
+ ```
279
+ biblicus query --corpus corpora/story --query "Primary button style preference" \\
280
+ | biblicus context-pack build
281
+ ```
282
+
283
+ Most production systems also apply a budget when building context. If you want a precise token budget, the budgeting logic needs a specific tokenizer and should be treated as its own stage.
284
+
285
+ ## Pipeline diagram
286
+
287
+ This diagram shows how a corpus becomes evidence for your assistant. Your code decides how to turn evidence into context and how to call a model.
288
+
289
+ ```mermaid
290
+ %%{init: {"theme": "base", "themeVariables": {"primaryColor": "#f3e5f5", "primaryTextColor": "#111111", "primaryBorderColor": "#8e24aa", "lineColor": "#90a4ae", "secondaryColor": "#eceff1", "tertiaryColor": "#ffffff"}, "flowchart": {"useMaxWidth": true, "nodeSpacing": 18, "rankSpacing": 22}}}%%
291
+ flowchart TB
292
+ subgraph Legend[Legend]
293
+ direction LR
294
+ LegendArtifact[Stored artifact or evidence]
295
+ LegendStep[Step]
296
+ LegendArtifact --- LegendStep
297
+ end
298
+
299
+ subgraph Main[" "]
300
+ direction TB
301
+
302
+ subgraph Pipeline[" "]
303
+ direction TB
304
+
305
+ subgraph RowStable[Stable core]
306
+ direction TB
307
+ Source[Source items] --> Ingest[Ingest] --> Raw[Raw item files] --> Catalog[Catalog file]
308
+ end
309
+
310
+ subgraph RowExtraction[Pluggable: extraction pipeline]
311
+ direction TB
312
+ Catalog --> Extract[Extract pipeline] --> ExtractedText[Extracted text artifacts] --> ExtractionRun[Extraction run manifest]
313
+ end
314
+
315
+ subgraph RowRetrieval[Pluggable: retrieval backend]
316
+ direction TB
317
+ ExtractionRun --> Build[Build run] --> BackendIndex[Backend index] --> Run[Run manifest] --> Retrieve[Retrieve] --> Rerank[Rerank optional] --> Filter[Filter optional] --> Evidence[Evidence]
318
+ end
319
+
320
+ subgraph RowContext[Context]
321
+ direction TB
322
+ Evidence --> ContextPack[Context pack] --> FitTokens[Fit tokens optional] --> Context[Assistant context]
323
+ end
324
+
325
+ subgraph RowYourCode[Your code]
326
+ direction TB
327
+ Context --> Model[Large language model call] --> Answer[Answer]
328
+ end
329
+ end
330
+
331
+ style RowStable fill:#ffffff,stroke:#8e24aa,stroke-width:2px,color:#111111
332
+ style RowExtraction fill:#ffffff,stroke:#5e35b1,stroke-dasharray:6 3,stroke-width:2px,color:#111111
333
+ style RowRetrieval fill:#ffffff,stroke:#1e88e5,stroke-dasharray:6 3,stroke-width:2px,color:#111111
334
+ style RowContext fill:#ffffff,stroke:#7b1fa2,stroke-width:2px,color:#111111
335
+ style RowYourCode fill:#ffffff,stroke:#d81b60,stroke-width:2px,color:#111111
336
+
337
+ style Raw fill:#f3e5f5,stroke:#8e24aa,color:#111111
338
+ style Catalog fill:#f3e5f5,stroke:#8e24aa,color:#111111
339
+ style ExtractedText fill:#f3e5f5,stroke:#8e24aa,color:#111111
340
+ style ExtractionRun fill:#f3e5f5,stroke:#8e24aa,color:#111111
341
+ style BackendIndex fill:#f3e5f5,stroke:#8e24aa,color:#111111
342
+ style Run fill:#f3e5f5,stroke:#8e24aa,color:#111111
343
+ style Evidence fill:#f3e5f5,stroke:#8e24aa,color:#111111
344
+ style ContextPack fill:#f3e5f5,stroke:#8e24aa,color:#111111
345
+ style Context fill:#f3e5f5,stroke:#8e24aa,color:#111111
346
+ style Answer fill:#f3e5f5,stroke:#8e24aa,color:#111111
347
+ style Source fill:#f3e5f5,stroke:#8e24aa,color:#111111
348
+
349
+ style Ingest fill:#eceff1,stroke:#90a4ae,color:#111111
350
+ style Extract fill:#eceff1,stroke:#90a4ae,color:#111111
351
+ style Build fill:#eceff1,stroke:#90a4ae,color:#111111
352
+ style Retrieve fill:#eceff1,stroke:#90a4ae,color:#111111
353
+ style Rerank fill:#eceff1,stroke:#90a4ae,color:#111111
354
+ style Filter fill:#eceff1,stroke:#90a4ae,color:#111111
355
+ style FitTokens fill:#eceff1,stroke:#90a4ae,color:#111111
356
+ style Model fill:#eceff1,stroke:#90a4ae,color:#111111
357
+ end
358
+
359
+ style Legend fill:#ffffff,stroke:#ffffff,color:#111111
360
+ style Main fill:#ffffff,stroke:#ffffff,color:#111111
361
+ style Pipeline fill:#ffffff,stroke:#ffffff,color:#111111
362
+ style LegendArtifact fill:#f3e5f5,stroke:#8e24aa,color:#111111
363
+ style LegendStep fill:#eceff1,stroke:#90a4ae,color:#111111
364
+ ```
365
+
220
366
  ## Python usage
221
367
 
222
368
  From Python, the same flow is available through the Corpus class and backend interfaces. The public surface area is small on purpose.
@@ -229,30 +375,28 @@ From Python, the same flow is available through the Corpus class and backend int
229
375
  - Query a run with `backend.query`.
230
376
  - Evaluate with `evaluate_run`.
231
377
 
232
- ## How it fits into an assistant
233
-
234
- In an assistant system, retrieval usually produces context for a model call. This library treats evidence as the primary output so you can decide how to use it.
235
-
236
- - Use a corpus as the source of truth for raw items.
237
- - Use a backend run to build any derived artifacts needed for retrieval.
238
- - Use queries to obtain evidence objects.
239
- - Convert evidence into the format your framework expects, such as message content, tool output, or citations.
240
-
241
378
  ## Learn more
242
379
 
243
380
  Full documentation is published on GitHub Pages: https://anthusai.github.io/Biblicus/
244
381
 
245
- The documents below are written to be read in order.
382
+ The documents below follow the pipeline from raw items to model context:
246
383
 
247
- - [Architecture][architecture]
248
- - [Roadmap][roadmap]
249
- - [Feature index][feature-index]
250
384
  - [Corpus][corpus]
251
385
  - [Text extraction][text-extraction]
252
- - [User configuration][user-configuration]
253
386
  - [Backends][backends]
387
+ - [Context packs][context-packs]
388
+ - [Testing and evaluation][testing]
389
+
390
+ Reference:
391
+
254
392
  - [Demos][demos]
255
- - [Testing][testing]
393
+ - [User configuration][user-configuration]
394
+
395
+ Design and implementation map:
396
+
397
+ - [Feature index][feature-index]
398
+ - [Roadmap][roadmap]
399
+ - [Architecture][architecture]
256
400
 
257
401
  ## Metadata and catalog
258
402
 
@@ -344,6 +488,7 @@ License terms are in `LICENSE`.
344
488
  [text-extraction]: docs/EXTRACTION.md
345
489
  [user-configuration]: docs/USER_CONFIGURATION.md
346
490
  [backends]: docs/BACKENDS.md
491
+ [context-packs]: docs/CONTEXT_PACK.md
347
492
  [demos]: docs/DEMOS.md
348
493
  [testing]: docs/TESTING.md
349
494