raglib-py 2.0.3__tar.gz → 2.1.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 (255) hide show
  1. {raglib_py-2.0.3 → raglib_py-2.1.0}/PKG-INFO +63 -17
  2. {raglib_py-2.0.3 → raglib_py-2.1.0}/README.md +54 -16
  3. {raglib_py-2.0.3 → raglib_py-2.1.0}/pyproject.toml +24 -1
  4. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/__init__.py +20 -4
  5. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/__init__.py +52 -49
  6. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/decision.py +72 -71
  7. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/generator.py +38 -12
  8. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/grader.py +109 -108
  9. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/hybrid_retriever.py +1 -1
  10. raglib_py-2.1.0/raglib/components/memory.py +274 -0
  11. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/multi_query_retriever.py +55 -56
  12. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/planner.py +68 -67
  13. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/query_expander.py +52 -51
  14. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/query_rewriter.py +85 -84
  15. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/refiner.py +42 -41
  16. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/reranker.py +161 -160
  17. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/retriever.py +53 -5
  18. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/router_retriever.py +112 -107
  19. raglib_py-2.1.0/raglib/components/sql_tool.py +327 -0
  20. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/web_retriever.py +3 -2
  21. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/constants.py +3 -1
  22. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/core/base.py +52 -24
  23. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/core/concurrency.py +5 -1
  24. raglib_py-2.1.0/raglib/core/runtime.py +123 -0
  25. raglib_py-2.1.0/raglib/core/text.py +199 -0
  26. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/base_embedding.py +12 -1
  27. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/cached_embedding.py +11 -0
  28. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/ollama_embedding.py +4 -1
  29. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/facade.py +96 -23
  30. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graph_context/engine.py +1099 -1140
  31. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/__init__.py +7 -1
  32. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/extractor.py +201 -197
  33. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/indexer.py +254 -258
  34. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/store/base.py +0 -3
  35. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/store/neo4j_store.py +0 -2
  36. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/store/networkx_store.py +264 -267
  37. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/base_client.py +37 -1
  38. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/langchain_adapter.py +125 -10
  39. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/mock_client.py +218 -205
  40. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/providers.py +0 -3
  41. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/__init__.py +12 -0
  42. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/chunk_splitter.py +124 -36
  43. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/document_loader.py +73 -10
  44. raglib_py-2.1.0/raglib/loaders/html_text.py +147 -0
  45. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/pdf_loader.py +6 -3
  46. raglib_py-2.1.0/raglib/loaders/structured_loaders.py +253 -0
  47. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/text_loader.py +6 -1
  48. raglib_py-2.1.0/raglib/loaders/web_loader.py +236 -0
  49. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/factory.py +4 -1
  50. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/advanced_rag.py +5 -1
  51. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/agentic_rag.py +14 -2
  52. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/corrective_rag.py +216 -219
  53. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/graph_rag.py +2 -0
  54. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/self_rag.py +2 -5
  55. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/tool_augmented_rag.py +46 -45
  56. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vectorstores/__init__.py +17 -0
  57. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vectorstores/chroma_store.py +17 -6
  58. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vectorstores/factory.py +65 -57
  59. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vectorstores/in_memory_store.py +31 -4
  60. raglib_py-2.1.0/raglib/vectorstores/pgvector_store.py +245 -0
  61. raglib_py-2.1.0/raglib/vectorstores/qdrant_store.py +221 -0
  62. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/visualize.py +299 -300
  63. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/README.md +22 -18
  64. raglib_py-2.0.3/raglib/components/memory.py +0 -121
  65. raglib_py-2.0.3/raglib/core/text.py +0 -97
  66. raglib_py-2.0.3/raglib/loaders/web_loader.py +0 -155
  67. {raglib_py-2.0.3 → raglib_py-2.1.0}/.gitignore +0 -0
  68. {raglib_py-2.0.3 → raglib_py-2.1.0}/LICENSE +0 -0
  69. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/__main__.py +0 -0
  70. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/cli.py +0 -0
  71. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/bm25.py +0 -0
  72. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/context_reducer.py +0 -0
  73. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/deduplicator.py +0 -0
  74. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/evaluator.py +0 -0
  75. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/multi_hop_retriever.py +0 -0
  76. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/reflection.py +0 -0
  77. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/components/tools.py +0 -0
  78. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/core/__init__.py +0 -0
  79. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/core/fusion.py +0 -0
  80. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/core/intents.py +0 -0
  81. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/core/parsing.py +0 -0
  82. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/core/tracing.py +0 -0
  83. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/__init__.py +0 -0
  84. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/embedding_factory.py +0 -0
  85. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/google_embedding.py +0 -0
  86. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/huggingface_embedding.py +0 -0
  87. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/mock_embedding.py +0 -0
  88. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/embedding/openai_embedding.py +0 -0
  89. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/eval/__init__.py +0 -0
  90. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graph_context/__init__.py +0 -0
  91. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graph_context/schemas.py +0 -0
  92. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/communities.py +0 -0
  93. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/schemas.py +0 -0
  94. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/search.py +0 -0
  95. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/graphrag/store/__init__.py +0 -0
  96. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/__init__.py +0 -0
  97. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/constants.py +0 -0
  98. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/provider_detector.py +0 -0
  99. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/llm/resilience.py +0 -0
  100. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/exceptions.py +0 -0
  101. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/pptx_loader.py +0 -0
  102. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/loaders/word_loader.py +0 -0
  103. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/preprocessing/__init__.py +0 -0
  104. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/preprocessing/chunk_splitter.py +0 -0
  105. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/__init__.py +0 -0
  106. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/base_provider.py +0 -0
  107. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/bing_provider.py +0 -0
  108. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/brave_provider.py +0 -0
  109. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/duckduckgo_provider.py +0 -0
  110. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/exa_provider.py +0 -0
  111. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/google_cse_provider.py +0 -0
  112. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/searxng_provider.py +0 -0
  113. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/serpapi_provider.py +0 -0
  114. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/providers/tavily_provider.py +0 -0
  115. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/quick.py +0 -0
  116. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/__init__.py +0 -0
  117. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/hybrid_rag.py +0 -0
  118. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/memory_rag.py +0 -0
  119. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/multi_hop_rag.py +0 -0
  120. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/multi_query_rag.py +0 -0
  121. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/naive_rag.py +0 -0
  122. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/routing_rag.py +0 -0
  123. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/rag_types/web_rag.py +0 -0
  124. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/schemas.py +0 -0
  125. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/session/__init__.py +0 -0
  126. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/session/interactive.py +0 -0
  127. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vectorstores/base_store.py +0 -0
  128. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vision/__init__.py +0 -0
  129. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vision/anthropic_vision.py +0 -0
  130. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vision/base_vision.py +0 -0
  131. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vision/google_vision.py +0 -0
  132. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vision/mock_vision.py +0 -0
  133. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vision/openai_vision.py +0 -0
  134. {raglib_py-2.0.3 → raglib_py-2.1.0}/raglib/vision/vision_factory.py +0 -0
  135. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/code-frame/LICENSE +0 -0
  136. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/code-frame/README.md +0 -0
  137. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/compat-data/LICENSE +0 -0
  138. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/compat-data/README.md +0 -0
  139. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/core/LICENSE +0 -0
  140. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/core/README.md +0 -0
  141. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/generator/LICENSE +0 -0
  142. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/generator/README.md +0 -0
  143. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-compilation-targets/LICENSE +0 -0
  144. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-compilation-targets/README.md +0 -0
  145. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-globals/LICENSE +0 -0
  146. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-globals/README.md +0 -0
  147. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-module-imports/LICENSE +0 -0
  148. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-module-imports/README.md +0 -0
  149. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-module-transforms/LICENSE +0 -0
  150. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-module-transforms/README.md +0 -0
  151. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-plugin-utils/LICENSE +0 -0
  152. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-plugin-utils/README.md +0 -0
  153. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-string-parser/LICENSE +0 -0
  154. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-string-parser/README.md +0 -0
  155. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-validator-identifier/LICENSE +0 -0
  156. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-validator-identifier/README.md +0 -0
  157. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-validator-option/LICENSE +0 -0
  158. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helper-validator-option/README.md +0 -0
  159. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helpers/LICENSE +0 -0
  160. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/helpers/README.md +0 -0
  161. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/parser/LICENSE +0 -0
  162. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/parser/README.md +0 -0
  163. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/plugin-transform-react-jsx-self/LICENSE +0 -0
  164. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/plugin-transform-react-jsx-self/README.md +0 -0
  165. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/plugin-transform-react-jsx-source/LICENSE +0 -0
  166. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/plugin-transform-react-jsx-source/README.md +0 -0
  167. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/template/LICENSE +0 -0
  168. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/template/README.md +0 -0
  169. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/traverse/LICENSE +0 -0
  170. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/traverse/README.md +0 -0
  171. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/types/LICENSE +0 -0
  172. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@babel/types/README.md +0 -0
  173. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@esbuild/win32-x64/README.md +0 -0
  174. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/gen-mapping/LICENSE +0 -0
  175. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/gen-mapping/README.md +0 -0
  176. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/remapping/LICENSE +0 -0
  177. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/remapping/README.md +0 -0
  178. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/resolve-uri/LICENSE +0 -0
  179. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/resolve-uri/README.md +0 -0
  180. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/sourcemap-codec/LICENSE +0 -0
  181. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/sourcemap-codec/README.md +0 -0
  182. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/trace-mapping/LICENSE +0 -0
  183. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@jridgewell/trace-mapping/README.md +0 -0
  184. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@rolldown/pluginutils/LICENSE +0 -0
  185. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@rollup/rollup-win32-x64-gnu/README.md +0 -0
  186. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@rollup/rollup-win32-x64-msvc/README.md +0 -0
  187. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__core/LICENSE +0 -0
  188. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__core/README.md +0 -0
  189. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__generator/LICENSE +0 -0
  190. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__generator/README.md +0 -0
  191. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__template/LICENSE +0 -0
  192. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__template/README.md +0 -0
  193. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__traverse/LICENSE +0 -0
  194. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/babel__traverse/README.md +0 -0
  195. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/estree/LICENSE +0 -0
  196. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/estree/README.md +0 -0
  197. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/prop-types/LICENSE +0 -0
  198. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/prop-types/README.md +0 -0
  199. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/react/LICENSE +0 -0
  200. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/react/README.md +0 -0
  201. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/react-dom/LICENSE +0 -0
  202. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@types/react-dom/README.md +0 -0
  203. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@vitejs/plugin-react/LICENSE +0 -0
  204. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/@vitejs/plugin-react/README.md +0 -0
  205. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/baseline-browser-mapping/README.md +0 -0
  206. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/browserslist/LICENSE +0 -0
  207. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/browserslist/README.md +0 -0
  208. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/caniuse-lite/LICENSE +0 -0
  209. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/caniuse-lite/README.md +0 -0
  210. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/convert-source-map/LICENSE +0 -0
  211. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/convert-source-map/README.md +0 -0
  212. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/csstype/LICENSE +0 -0
  213. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/csstype/README.md +0 -0
  214. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/debug/LICENSE +0 -0
  215. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/debug/README.md +0 -0
  216. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/electron-to-chromium/LICENSE +0 -0
  217. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/electron-to-chromium/README.md +0 -0
  218. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/esbuild/README.md +0 -0
  219. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/gensync/LICENSE +0 -0
  220. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/gensync/README.md +0 -0
  221. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/js-tokens/LICENSE +0 -0
  222. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/js-tokens/README.md +0 -0
  223. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/jsesc/README.md +0 -0
  224. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/json5/README.md +0 -0
  225. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/loose-envify/LICENSE +0 -0
  226. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/loose-envify/README.md +0 -0
  227. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/lru-cache/LICENSE +0 -0
  228. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/lru-cache/README.md +0 -0
  229. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/nanoid/LICENSE +0 -0
  230. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/nanoid/README.md +0 -0
  231. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/node-releases/LICENSE +0 -0
  232. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/node-releases/README.md +0 -0
  233. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/picocolors/LICENSE +0 -0
  234. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/picocolors/README.md +0 -0
  235. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/postcss/LICENSE +0 -0
  236. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/postcss/README.md +0 -0
  237. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/react/LICENSE +0 -0
  238. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/react/README.md +0 -0
  239. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/react-dom/LICENSE +0 -0
  240. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/react-dom/README.md +0 -0
  241. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/react-refresh/LICENSE +0 -0
  242. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/react-refresh/README.md +0 -0
  243. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/rollup/README.md +0 -0
  244. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/scheduler/LICENSE +0 -0
  245. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/scheduler/README.md +0 -0
  246. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/semver/LICENSE +0 -0
  247. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/semver/README.md +0 -0
  248. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/source-map-js/LICENSE +0 -0
  249. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/source-map-js/README.md +0 -0
  250. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/typescript/README.md +0 -0
  251. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/update-browserslist-db/LICENSE +0 -0
  252. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/update-browserslist-db/README.md +0 -0
  253. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/vite/README.md +0 -0
  254. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/yallist/LICENSE +0 -0
  255. {raglib_py-2.0.3 → raglib_py-2.1.0}/site/node_modules/yallist/README.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: raglib-py
3
- Version: 2.0.3
3
+ Version: 2.1.0
4
4
  Summary: Modular Retrieval-Augmented Generation: hybrid search, reranking, CRAG, Self-RAG, agentic and GraphRAG pipelines
5
5
  Project-URL: Homepage, https://github.com/himanshuhs9011/raglib
6
6
  Project-URL: Documentation, https://github.com/himanshuhs9011/raglib/blob/main/docs/USAGE.md
@@ -53,6 +53,7 @@ Requires-Dist: langchain-ollama>=0.1.0; extra == 'all'
53
53
  Requires-Dist: langchain-openai>=0.1.0; extra == 'all'
54
54
  Requires-Dist: networkx>=3.0; extra == 'all'
55
55
  Requires-Dist: numpy>=1.24; extra == 'all'
56
+ Requires-Dist: openpyxl>=3.1; extra == 'all'
56
57
  Requires-Dist: pymupdf>=1.23.0; extra == 'all'
57
58
  Requires-Dist: python-docx>=1.0.0; extra == 'all'
58
59
  Requires-Dist: python-pptx>=0.6.21; extra == 'all'
@@ -74,6 +75,7 @@ Provides-Extra: cohere
74
75
  Requires-Dist: cohere>=5.0.0; extra == 'cohere'
75
76
  Provides-Extra: dev
76
77
  Requires-Dist: build>=1.0.0; extra == 'dev'
78
+ Requires-Dist: mypy>=1.8; extra == 'dev'
77
79
  Requires-Dist: networkx>=3.0; extra == 'dev'
78
80
  Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
79
81
  Requires-Dist: pytest>=7.4.0; extra == 'dev'
@@ -115,8 +117,12 @@ Requires-Dist: langchain-core>=0.2.0; extra == 'openrouter'
115
117
  Requires-Dist: langchain-openai>=0.1.0; extra == 'openrouter'
116
118
  Provides-Extra: pdf
117
119
  Requires-Dist: pymupdf>=1.23.0; extra == 'pdf'
120
+ Provides-Extra: pgvector
121
+ Requires-Dist: psycopg[binary]>=3.1; extra == 'pgvector'
118
122
  Provides-Extra: pptx
119
123
  Requires-Dist: python-pptx>=0.6.21; extra == 'pptx'
124
+ Provides-Extra: qdrant
125
+ Requires-Dist: qdrant-client>=1.10.0; extra == 'qdrant'
120
126
  Provides-Extra: rerank
121
127
  Requires-Dist: sentence-transformers>=2.6.0; extra == 'rerank'
122
128
  Provides-Extra: serpapi
@@ -125,6 +131,8 @@ Provides-Extra: tavily
125
131
  Requires-Dist: tavily-python>=0.2.0; extra == 'tavily'
126
132
  Provides-Extra: web
127
133
  Requires-Dist: ddgs>=6.0.0; extra == 'web'
134
+ Provides-Extra: xlsx
135
+ Requires-Dist: openpyxl>=3.1; extra == 'xlsx'
128
136
  Description-Content-Type: text/markdown
129
137
 
130
138
  # raglib-py (v2.0.0) — Complete Documentation & Developer Guide
@@ -181,9 +189,12 @@ pip install "raglib-py[hf]" # local HuggingFace / SentenceTransform
181
189
  pip install "raglib-py[rerank]" # cross-encoder reranker (bge-reranker)
182
190
  pip install "raglib-py[fast]" # numpy vector math + tiktoken token counting
183
191
  pip install "raglib-py[chroma]" # persistent ChromaDB vector store
192
+ pip install "raglib-py[qdrant]" # Qdrant vector store (in-process, on-disk or server)
193
+ pip install "raglib-py[pgvector]" # PostgreSQL + pgvector vector store
184
194
  pip install "raglib-py[graph]" # GraphRAG community detection (networkx)
185
195
  pip install "raglib-py[neo4j]" # Neo4j graph store
186
196
  pip install "raglib-py[pdf,docx,pptx]" # document loaders
197
+ pip install "raglib-py[xlsx]" # Excel workbooks (loader + SQLTool)
187
198
  pip install "raglib-py[web]" # DuckDuckGo web search
188
199
  pip install "raglib-py[tavily,serpapi]" # Tavily & SerpAPI SDKs
189
200
  ```
@@ -316,13 +327,15 @@ rag = RAG(
316
327
  offline=None, # True -> explicit mock models (or RAGLIB_OFFLINE=1)
317
328
  llm_cache=True, # LRU cache for identical (system, prompt) LLM calls
318
329
  llm_timeout=60.0, llm_max_retries=2, # per-call timeout + exponential-backoff retries
330
+ llm_temperature=0.0, # sampling temperature for models built from a provider name
331
+ llm_max_tokens=None, # cap on answer length (mapped to each provider's parameter)
319
332
  # ---- pipeline
320
333
  rag_type="advanced", # One of the 14 RAG architectures
321
334
  top_k=5, # Documents passed to generation
322
335
  max_context_tokens=3000, # Generation context budget (tiktoken when installed)
323
336
  rewrite_query=False, # LLM query rewriting before retrieval
324
337
  # ---- chunking
325
- chunk_size=400, chunk_overlap=50, # words
338
+ chunk_size=400, chunk_overlap=50, # words (each Chinese/Japanese/Thai character counts as one); a hard limit
326
339
  chunking_strategy="fixed", # "fixed" | "recursive" | "llm"
327
340
  # ---- retrieval
328
341
  retrieval_mode=None, # "hybrid" (default with embeddings) | "dense" | "sparse"
@@ -333,11 +346,12 @@ rag = RAG(
333
346
  neighbor_window=0, # small-to-big: attach N neighbouring chunks to each hit
334
347
  reranker="none", # "none" | "cross_encoder" | "cohere" | "llm"
335
348
  reranker_model=None, reranker_api_key=None,
336
- vector_db=None, # "memory" (default) | "chroma" | BaseVectorStore
349
+ vector_db=None, # "memory" (default) | "chroma" | "qdrant" | "pgvector" | BaseVectorStore
337
350
  vector_db_kwargs=None, # e.g. {"persist_directory": "...", "collection_name": "...", "host": ...}
338
351
  # ---- memory
339
352
  memory=None, # True to enable conversation memory for any rag_type
340
353
  max_history_turns=10, max_history_tokens=1200,
354
+ conversation_store=None, # e.g. SQLiteConversationStore("chats.db") to persist sessions
341
355
  # ---- web search (OFF unless configured)
342
356
  web_search_provider=None, # "duckduckgo" | "local" | "tavily" | "serpapi" | "brave" | "bing" | "google_cse" | "exa" | "searxng"
343
357
  web_search_api_key=None, web_search_base_url=None, web_search_cse_id=None,
@@ -347,7 +361,8 @@ rag = RAG(
347
361
  graph_store=None, # "networkx" (default) | "neo4j" | BaseGraphStore
348
362
  graph_kwargs=None, # see section 8
349
363
  # ---- agents & observability
350
- tools=None, # [Tool(...)] for rag_type="agentic"
364
+ tools=None, # [Tool(...), SQLTool(...)] for rag_type="agentic"
365
+ strict=False, # True: raise when an optional step fails instead of degrading
351
366
  on_event=None, # callback(TraceEvent) for every pipeline stage
352
367
  output_dir=None, # write each query result as JSON
353
368
  **rag_type_kwargs, # forwarded to the orchestrator (e.g. max_hops=3, search_mode="global")
@@ -363,7 +378,7 @@ rag = RAG(
363
378
  | `await rag.aquery(question, ...)` | Async query. |
364
379
  | `rag.add(source) -> int` | Idempotent upsert: unchanged documents are skipped, changed ones replace their old chunks. Returns new chunks indexed. |
365
380
  | `rag.update(source)` / `rag.delete(source)` | Re-ingest changed sources / remove every chunk (and graph entity) from a source. |
366
- | `rag.save(dir)` / `rag.load(dir)` | Persist and restore the chunk index, in-memory vectors and knowledge graph without re-embedding. |
381
+ | `rag.save(dir)` / `rag.load(dir, allow_model_change=False)` | Persist and restore the chunk index, in-memory vectors and knowledge graph without re-embedding. Files are written atomically; `load` refuses an index built with a different embedding model (pass `allow_model_change=True` to re-embed). |
367
382
  | `rag.reset_memory(session_id=None)` | Clear one conversation (or all). |
368
383
  | `rag.evaluate(dataset, judge_llm=None)` | Retrieval + answer-quality metrics (section 13). |
369
384
  | `rag.rebuild_graph_communities()` | Re-cluster the knowledge graph and refresh changed community reports. |
@@ -382,12 +397,18 @@ rag = RAG(
382
397
  | **PDF file** (`.pdf`) | `"report.pdf"` | `PDFLoader` (one document per page; scanned pages via `vision_llm` OCR, otherwise skipped with a warning) |
383
398
  | **Word file** (`.docx`) | `"spec.docx"` | `WordLoader` |
384
399
  | **PowerPoint** (`.pptx`) | `"slides.pptx"` | `PPTXLoader` (one document per slide) |
385
- | **Text / Markdown** (`.txt`, `.md`) | `"notes.md"` | `TextLoader` |
386
- | **Web URL** (`http://`, `https://`) | `"https://example.com/docs"` | `WebLoader` (strips `<script>`/`<style>` and extracts visible text) |
400
+ | **Text / Markdown** (`.txt`, `.md`, `.rst`, `.log`, ...) | `"notes.md"` | `TextLoader` |
401
+ | **Source code & config** (`.py`, `.js`, `.ts`, `.java`, `.go`, `.sql`, `.yaml`, `.toml`, ...) | `"src/"` | `TextLoader` |
402
+ | **HTML file** (`.html`, `.htm`) | `"page.html"` | `HTMLFileLoader` (headings, lists and tables kept; nav/footer dropped; title in metadata) |
403
+ | **CSV / TSV** | `"people.csv"` | `CSVLoader` (one `column: value; ...` line per row) |
404
+ | **JSON / JSONL** | `"items.jsonl"` | `JSONLoader` (one line per record; other JSON pretty-printed) |
405
+ | **Excel** (`.xlsx`) | `"sales.xlsx"` | `XLSXLoader` (one document per sheet; `pip install raglib-py[xlsx]`) |
406
+ | **EPUB** (`.epub`) | `"book.epub"` | `EPUBLoader` (one document per chapter, in reading order) |
407
+ | **Web URL** (`http://`, `https://`) | `"https://example.com/docs"` | `WebLoader` (keeps headings, paragraphs, lists and tables; prefers `<main>`/`<article>`; drops nav/footer/sidebars; PDF responses are parsed as PDFs) |
387
408
  | **Raw text string** | `"RAG grounds LLM outputs."` | Wrapped directly as a `Document` (content-hash id) |
388
409
  | **List of mixed sources** | `["a.pdf", "https://...", "raw note"]` | Each item is routed to its matching loader |
389
410
 
390
- > **Safety Note:** If a string looks like a file path (e.g., `"missing_file.pdf"`) and does not exist on disk, `DocumentLoader` raises `FileNotFoundError` immediately rather than silently indexing the filename string.
411
+ > **Safety Note:** If a string looks like a file or folder path (`"missing_file.pdf"`, `"./my_docs"`, `"data/docs"`, `"C:\docs"`) and does not exist, `DocumentLoader` raises `FileNotFoundError` instead of silently indexing the string as text. Folder scans skip `.git`, `node_modules`, virtualenvs, caches and hidden files, and binary files are skipped with a warning.
391
412
 
392
413
  ---
393
414
 
@@ -399,7 +420,9 @@ rag = RAG(
399
420
  | **`"recursive"`** | `"recursive_character"` | Splits along structural separators (`"\n\n"`, `"\n"`, `". "`, ... `""`) to keep paragraphs together, then applies overlap. | Markdown, structured reports. |
400
421
  | **`"llm"`** | `"semantic"`, `"llm_semantic"` | The LLM groups numbered sentences at topic shifts (`CHUNK: start-end`); falls back to `"recursive"` without an LLM. | High-value documents with shifting topics. |
401
422
 
402
- Every chunk gets a stable id `{parent_id}_chunk_{n}_{content_hash}` plus `parent_id`, `prev_id` and `next_id` metadata. That's what makes re-ingestion idempotent and neighbour expansion possible.
423
+ `chunk_size` is a hard limit for `fixed` and `recursive`: a line or sentence longer than it is split further, so log files, one-record-per-line data and text without punctuation never end up as one giant chunk. Line breaks inside a chunk are kept. For Chinese, Japanese, Thai, Lao, Khmer and Myanmar each character counts as one unit, and `。!?` end sentences.
424
+
425
+ Every chunk gets a stable id `{parent_id}_chunk_{n}_{content_hash}` plus `parent_id`, `prev_id` and `next_id` metadata. That's what makes re-ingestion idempotent and neighbour expansion possible. Consecutive PDF pages and slides are linked too, so `neighbor_window` can follow text across a page break.
403
426
 
404
427
  ```python
405
428
  from raglib import ChunkSplitter, Document, MockLLMClient
@@ -419,7 +442,7 @@ for chunk in splitter.split(docs):
419
442
  - `fusion="relative"` *(default)* scores every candidate on **both** signals, min-max normalizes each, and blends them with `hybrid_alpha`. A chunk that is decisive in one signal (e.g. the only chunk containing `INV-2024-0042`) is never out-voted by chunks that are mediocre in both.
420
443
  - `fusion="rrf"` uses classic rank-only Reciprocal Rank Fusion.
421
444
 
422
- Tokenization is Unicode-aware, including combining marks, so Hindi, Bengali, Tamil, Arabic, Thai, Cyrillic and accented Latin all work for BM25.
445
+ Tokenization is Unicode-aware, including combining marks, so Hindi, Bengali, Tamil, Arabic, Cyrillic and accented Latin all work for BM25. Scripts written without spaces (Chinese, Japanese, Thai, Lao, Khmer, Myanmar) are indexed as overlapping character bigrams (`東京都` -> `東京`, `京都`), so keyword search works for them without a word segmenter.
423
446
 
424
447
  ```python
425
448
  from raglib import RAG
@@ -452,7 +475,7 @@ Select via `RAG(..., rag_type="<name>")` or import the class from `raglib`. Ever
452
475
  | `rag_type` | Class | What it actually does | LLM calls / query* | Best Use Case |
453
476
  | :--- | :--- | :--- | :--- | :--- |
454
477
  | **`"naive"`** | `NaiveRAG` | Retrieve -> generate | 1 | Baseline |
455
- | **`"advanced"`** *(default)* | `AdvancedRAG` | Hybrid retrieve -> rerank -> dedupe -> cited generate | 1 | Most production Q&A |
478
+ | **`"advanced"`** *(default)* | `AdvancedRAG` | Hybrid retrieve -> rerank (when `reranker` is set; default `"none"`) -> dedupe -> cited generate | 1 | Most production Q&A |
456
479
  | **`"hybrid"`** | `HybridRAG` | Forces BM25 + dense hybrid retrieval | 1 | Keyword-heavy corpora (IDs, codes, names) |
457
480
  | **`"hybrid_web"`** | `HybridRAG(include_web=True)` | Corpus + live web, fused | 1 | Private docs + fresh public info |
458
481
  | **`"corrective"`** | `CorrectiveRAG` | Batched relevance grading -> CORRECT: keep relevant sentence strips / INCORRECT: search / AMBIGUOUS: both | 2–4 | Corpora that may not contain the answer |
@@ -468,6 +491,19 @@ Select via `RAG(..., rag_type="<name>")` or import the class from `raglib`. Ever
468
491
 
469
492
  \* Excluding the optional rewrite/condense steps.
470
493
 
494
+ ### Counting and aggregate questions (`SQLTool`)
495
+
496
+ Retrieval answers from the top-k chunks, so a question like "how many engineers are based in Tokyo?" over a 5,000-row table cannot be counted correctly: the model only ever sees a few chunks. For tabular data, give the agent an `SQLTool`. The LLM writes one read-only `SELECT`, which SQLite runs over every row:
497
+
498
+ ```python
499
+ from raglib import RAG, SQLTool
500
+
501
+ rag = RAG("people.csv", llm="openai", rag_type="agentic", tools=[SQLTool.from_files("people.csv")])
502
+ print(rag.query("How many engineers are based in Tokyo?").answer)
503
+ ```
504
+
505
+ `SQLTool` loads `.csv`, `.tsv`, `.xlsx`, `.json` and `.jsonl` files (or `add_rows(table, header, rows)`) into a private in-memory SQLite database. An SQLite authorizer allows only reads, so writes, `ATTACH` and `PRAGMA` are refused. Queries time out after `timeout_seconds` (default 5) and results are capped at `max_rows`.
506
+
471
507
  **Web search is never used unless you configure it** (`web_search_provider=...`). The exceptions are `web` and `hybrid_web`, which default to DuckDuckGo. Corrective RAG without a web provider retries the corpus with a refined query instead.
472
508
 
473
509
  ---
@@ -671,10 +707,12 @@ If `embedding_llm` is omitted, raglib uses the chat provider's embeddings (OpenA
671
707
  ### Vector Stores (`vector_db`)
672
708
 
673
709
  - **`"memory"`** *(default)*: in-RAM cosine search (numpy-accelerated when installed), persisted with `rag.save()` / `rag.load()`.
710
+ - **`"qdrant"`**: Qdrant (`pip install raglib-py[qdrant]`). In-process by default; `vector_db_kwargs={"path": "./qdrant"}` persists to disk, `{"url": "http://localhost:6333", "api_key": ...}` uses a server or Qdrant Cloud. Filters run inside Qdrant.
711
+ - **`"pgvector"`**: PostgreSQL with the pgvector extension (`pip install raglib-py[pgvector]`), e.g. `vector_db_kwargs={"dsn": "postgresql://user:pass@host/db", "table_name": "docs"}`. Uses an HNSW cosine index when available; filters become parameterized SQL on a JSONB column.
674
712
  - **`"chroma"`**: ChromaDB in cosine space. Each `RAG` gets its **own collection** unless you name one, so instances never see each other's data. Use `{"persist_directory": ..., "collection_name": ...}` for a durable index or `{"host": ..., "port": ...}` for a Chroma server.
675
713
  - **Your own**: subclass `BaseVectorStore` (`upsert`, `query(filters=...)`, `delete`, `count`).
676
714
 
677
- Initialization errors are raised. Pass `vector_db_kwargs={"fallback_to_memory": True}` to opt into a fallback.
715
+ Initialization errors are raised. Pass `vector_db_kwargs={"fallback_to_memory": True}` to opt into a fallback. Every store refuses vectors of a different size than the ones it holds, so switching embedding models fails loudly instead of returning meaningless matches.
678
716
 
679
717
  ---
680
718
 
@@ -709,6 +747,10 @@ rag.query("What is our authentication service called?", session_id="user-42")
709
747
  rag.query("Which downstream services depend on it?", session_id="user-42")
710
748
  rag.reset_memory("user-42")
711
749
 
750
+ # Persist conversations across restarts and worker processes
751
+ from raglib import SQLiteConversationStore
752
+ rag = RAG("docs/", chat_llm="openai", memory=True, conversation_store=SQLiteConversationStore("chats.db", ttl_seconds=86400))
753
+
712
754
  # Streaming
713
755
  for token in rag.stream("Summarize the onboarding guide"):
714
756
  print(token, end="", flush=True)
@@ -719,7 +761,8 @@ for token in rag.stream("Summarize the onboarding guide"):
719
761
  # Tracing: every stage is timed; plug in LangSmith / OpenTelemetry / logging
720
762
  rag = RAG("docs/", chat_llm="openai", on_event=lambda e: print(e.stage, e.latency_ms, e.meta))
721
763
  result = rag.query("...")
722
- print(result.usage) # {"prompt_tokens": ..., "completion_tokens": ..., "latency_ms": ...}
764
+ print(result.usage) # answer call + totals over every LLM call of the query (see below)
765
+ print(result.metadata.get("degraded")) # optional steps that failed and fell back, if any
723
766
 
724
767
  rag.chat() # interactive terminal session with memory
725
768
  ```
@@ -781,7 +824,9 @@ result = pipeline.run("How does Corrective RAG handle low-scoring chunks?")
781
824
  print(result.answer, result.reasoning_trace)
782
825
  ```
783
826
 
784
- Subclass `BaseRAG` and override `retrieve(ctx)` (or `process_documents` / `generate` / `answer`) to build your own strategy. Condensation, memory, tracing, citations and streaming come for free.
827
+ Subclass `BaseRAG` and override `retrieve(ctx)` (or `process_documents` / `generate` / `answer`) to build your own strategy. Condensation, memory, tracing, citations, streaming, token usage and degradation reporting come for free. If you keep the default `retrieve`, it routes each query with `DecisionEngine` (corpus / web / both / none) and retries poor lexical matches with `Refiner`; the built-in strategies replace that step with their own.
828
+
829
+ Custom `BaseLLMClient` implementations can report token usage with `raglib.core.runtime.record_usage(prompt_tokens, completion_tokens)`, and custom steps can report fallbacks with `report_degraded("my_step", exc)` inside their `except` block.
785
830
 
786
831
  ---
787
832
 
@@ -798,8 +843,8 @@ from raglib import Document, GenerationResult, Citation, TraceEvent, QueryResult
798
843
  - `citations: List[Citation]` — `[n]` markers in the answer mapped to sources (`index`, `document_id`, `source`, `snippet`)
799
844
  - `reasoning_trace: List[str]` — human-readable pipeline steps
800
845
  - `trace_events: List[TraceEvent]` — `stage`, `latency_ms`, `meta`, `error` per stage
801
- - `usage: Dict` — prompt/completion tokens and total latency
802
- - `metadata: Dict` — pipeline name, standalone search query, session id, strategy details
846
+ - `usage: Dict` — `prompt_tokens` / `completion_tokens` of the answer call (`generation_usage_estimated` says whether they are the provider's counts or estimates), plus `llm_calls`, `total_prompt_tokens`, `total_completion_tokens`, `total_tokens` over every LLM call of the query (grading, routing, rewriting, ...), `usage_estimated`, and `latency_ms`
847
+ - `metadata: Dict` — pipeline name, standalone search query, session id, strategy details, and `degraded` (a list of `{component, error}` for optional steps that failed and fell back; with `RAG(strict=True)` those failures are raised instead)
803
848
  - **GraphRAG**: `raglib.graphrag.Entity`, `Relation`, `Community`
804
849
 
805
850
  ---
@@ -828,7 +873,8 @@ raglib graph papers/ --out graph.html
828
873
  | API keys | Read from env vars or arguments only, never logged. A chat key is only reused for embeddings from the same provider. | Keep keys in env vars or a secret manager. `.env.example` lists every variable. |
829
874
  | What leaves your machine | Questions, retrieved chunks and (with memory) chat history go to the LLM provider you chose. Chunks go to the embedding provider. Web search is off unless configured. | Use a local model (Ollama / LM Studio / vLLM) for confidential data. |
830
875
  | Logs | Questions, answers and document text are never logged at INFO or above. | Don't enable DEBUG logging in production if queries may contain personal data. |
831
- | User-supplied URLs | Private, loopback, link-local and metadata addresses are blocked (SSRF), redirects are re-checked, and responses are capped at 20 MB. | `allow_private_urls=True` only for trusted intranet sources. |
876
+ | User-supplied URLs | Private, loopback, link-local and metadata addresses are blocked (SSRF). The host is resolved once and the connection goes to the checked address, so DNS rebinding cannot reach internal services. Redirects are re-checked and responses are capped at 20 MB. With an `HTTPS_PROXY`, the proxy resolves hosts, so only the pre-check applies. | `allow_private_urls=True` only for trusted intranet sources. |
877
+ | `SQLTool` | Runs on a private in-memory copy of the tables; only read statements are authorized, one statement per call, with a timeout and a row cap. | Load only tables the agent may read. |
832
878
  | User-supplied file paths | `allowed_dirs=[...]` sandboxes file and folder sources (resolves `..` and symlinks). | Always set it when paths come from users. |
833
879
  | Prompt injection | Retrieved text is wrapped in `<source>` blocks with an instruction to treat it as data. | Treat answers as untrusted output; don't give agent tools destructive permissions. |
834
880
  | Multi-user | `session_id` isolates chat history. Documents are shared within one `RAG` instance. | Use one `RAG` per tenant, or `filters={"tenant": ...}` on every query. |
@@ -52,9 +52,12 @@ pip install "raglib-py[hf]" # local HuggingFace / SentenceTransform
52
52
  pip install "raglib-py[rerank]" # cross-encoder reranker (bge-reranker)
53
53
  pip install "raglib-py[fast]" # numpy vector math + tiktoken token counting
54
54
  pip install "raglib-py[chroma]" # persistent ChromaDB vector store
55
+ pip install "raglib-py[qdrant]" # Qdrant vector store (in-process, on-disk or server)
56
+ pip install "raglib-py[pgvector]" # PostgreSQL + pgvector vector store
55
57
  pip install "raglib-py[graph]" # GraphRAG community detection (networkx)
56
58
  pip install "raglib-py[neo4j]" # Neo4j graph store
57
59
  pip install "raglib-py[pdf,docx,pptx]" # document loaders
60
+ pip install "raglib-py[xlsx]" # Excel workbooks (loader + SQLTool)
58
61
  pip install "raglib-py[web]" # DuckDuckGo web search
59
62
  pip install "raglib-py[tavily,serpapi]" # Tavily & SerpAPI SDKs
60
63
  ```
@@ -187,13 +190,15 @@ rag = RAG(
187
190
  offline=None, # True -> explicit mock models (or RAGLIB_OFFLINE=1)
188
191
  llm_cache=True, # LRU cache for identical (system, prompt) LLM calls
189
192
  llm_timeout=60.0, llm_max_retries=2, # per-call timeout + exponential-backoff retries
193
+ llm_temperature=0.0, # sampling temperature for models built from a provider name
194
+ llm_max_tokens=None, # cap on answer length (mapped to each provider's parameter)
190
195
  # ---- pipeline
191
196
  rag_type="advanced", # One of the 14 RAG architectures
192
197
  top_k=5, # Documents passed to generation
193
198
  max_context_tokens=3000, # Generation context budget (tiktoken when installed)
194
199
  rewrite_query=False, # LLM query rewriting before retrieval
195
200
  # ---- chunking
196
- chunk_size=400, chunk_overlap=50, # words
201
+ chunk_size=400, chunk_overlap=50, # words (each Chinese/Japanese/Thai character counts as one); a hard limit
197
202
  chunking_strategy="fixed", # "fixed" | "recursive" | "llm"
198
203
  # ---- retrieval
199
204
  retrieval_mode=None, # "hybrid" (default with embeddings) | "dense" | "sparse"
@@ -204,11 +209,12 @@ rag = RAG(
204
209
  neighbor_window=0, # small-to-big: attach N neighbouring chunks to each hit
205
210
  reranker="none", # "none" | "cross_encoder" | "cohere" | "llm"
206
211
  reranker_model=None, reranker_api_key=None,
207
- vector_db=None, # "memory" (default) | "chroma" | BaseVectorStore
212
+ vector_db=None, # "memory" (default) | "chroma" | "qdrant" | "pgvector" | BaseVectorStore
208
213
  vector_db_kwargs=None, # e.g. {"persist_directory": "...", "collection_name": "...", "host": ...}
209
214
  # ---- memory
210
215
  memory=None, # True to enable conversation memory for any rag_type
211
216
  max_history_turns=10, max_history_tokens=1200,
217
+ conversation_store=None, # e.g. SQLiteConversationStore("chats.db") to persist sessions
212
218
  # ---- web search (OFF unless configured)
213
219
  web_search_provider=None, # "duckduckgo" | "local" | "tavily" | "serpapi" | "brave" | "bing" | "google_cse" | "exa" | "searxng"
214
220
  web_search_api_key=None, web_search_base_url=None, web_search_cse_id=None,
@@ -218,7 +224,8 @@ rag = RAG(
218
224
  graph_store=None, # "networkx" (default) | "neo4j" | BaseGraphStore
219
225
  graph_kwargs=None, # see section 8
220
226
  # ---- agents & observability
221
- tools=None, # [Tool(...)] for rag_type="agentic"
227
+ tools=None, # [Tool(...), SQLTool(...)] for rag_type="agentic"
228
+ strict=False, # True: raise when an optional step fails instead of degrading
222
229
  on_event=None, # callback(TraceEvent) for every pipeline stage
223
230
  output_dir=None, # write each query result as JSON
224
231
  **rag_type_kwargs, # forwarded to the orchestrator (e.g. max_hops=3, search_mode="global")
@@ -234,7 +241,7 @@ rag = RAG(
234
241
  | `await rag.aquery(question, ...)` | Async query. |
235
242
  | `rag.add(source) -> int` | Idempotent upsert: unchanged documents are skipped, changed ones replace their old chunks. Returns new chunks indexed. |
236
243
  | `rag.update(source)` / `rag.delete(source)` | Re-ingest changed sources / remove every chunk (and graph entity) from a source. |
237
- | `rag.save(dir)` / `rag.load(dir)` | Persist and restore the chunk index, in-memory vectors and knowledge graph without re-embedding. |
244
+ | `rag.save(dir)` / `rag.load(dir, allow_model_change=False)` | Persist and restore the chunk index, in-memory vectors and knowledge graph without re-embedding. Files are written atomically; `load` refuses an index built with a different embedding model (pass `allow_model_change=True` to re-embed). |
238
245
  | `rag.reset_memory(session_id=None)` | Clear one conversation (or all). |
239
246
  | `rag.evaluate(dataset, judge_llm=None)` | Retrieval + answer-quality metrics (section 13). |
240
247
  | `rag.rebuild_graph_communities()` | Re-cluster the knowledge graph and refresh changed community reports. |
@@ -253,12 +260,18 @@ rag = RAG(
253
260
  | **PDF file** (`.pdf`) | `"report.pdf"` | `PDFLoader` (one document per page; scanned pages via `vision_llm` OCR, otherwise skipped with a warning) |
254
261
  | **Word file** (`.docx`) | `"spec.docx"` | `WordLoader` |
255
262
  | **PowerPoint** (`.pptx`) | `"slides.pptx"` | `PPTXLoader` (one document per slide) |
256
- | **Text / Markdown** (`.txt`, `.md`) | `"notes.md"` | `TextLoader` |
257
- | **Web URL** (`http://`, `https://`) | `"https://example.com/docs"` | `WebLoader` (strips `<script>`/`<style>` and extracts visible text) |
263
+ | **Text / Markdown** (`.txt`, `.md`, `.rst`, `.log`, ...) | `"notes.md"` | `TextLoader` |
264
+ | **Source code & config** (`.py`, `.js`, `.ts`, `.java`, `.go`, `.sql`, `.yaml`, `.toml`, ...) | `"src/"` | `TextLoader` |
265
+ | **HTML file** (`.html`, `.htm`) | `"page.html"` | `HTMLFileLoader` (headings, lists and tables kept; nav/footer dropped; title in metadata) |
266
+ | **CSV / TSV** | `"people.csv"` | `CSVLoader` (one `column: value; ...` line per row) |
267
+ | **JSON / JSONL** | `"items.jsonl"` | `JSONLoader` (one line per record; other JSON pretty-printed) |
268
+ | **Excel** (`.xlsx`) | `"sales.xlsx"` | `XLSXLoader` (one document per sheet; `pip install raglib-py[xlsx]`) |
269
+ | **EPUB** (`.epub`) | `"book.epub"` | `EPUBLoader` (one document per chapter, in reading order) |
270
+ | **Web URL** (`http://`, `https://`) | `"https://example.com/docs"` | `WebLoader` (keeps headings, paragraphs, lists and tables; prefers `<main>`/`<article>`; drops nav/footer/sidebars; PDF responses are parsed as PDFs) |
258
271
  | **Raw text string** | `"RAG grounds LLM outputs."` | Wrapped directly as a `Document` (content-hash id) |
259
272
  | **List of mixed sources** | `["a.pdf", "https://...", "raw note"]` | Each item is routed to its matching loader |
260
273
 
261
- > **Safety Note:** If a string looks like a file path (e.g., `"missing_file.pdf"`) and does not exist on disk, `DocumentLoader` raises `FileNotFoundError` immediately rather than silently indexing the filename string.
274
+ > **Safety Note:** If a string looks like a file or folder path (`"missing_file.pdf"`, `"./my_docs"`, `"data/docs"`, `"C:\docs"`) and does not exist, `DocumentLoader` raises `FileNotFoundError` instead of silently indexing the string as text. Folder scans skip `.git`, `node_modules`, virtualenvs, caches and hidden files, and binary files are skipped with a warning.
262
275
 
263
276
  ---
264
277
 
@@ -270,7 +283,9 @@ rag = RAG(
270
283
  | **`"recursive"`** | `"recursive_character"` | Splits along structural separators (`"\n\n"`, `"\n"`, `". "`, ... `""`) to keep paragraphs together, then applies overlap. | Markdown, structured reports. |
271
284
  | **`"llm"`** | `"semantic"`, `"llm_semantic"` | The LLM groups numbered sentences at topic shifts (`CHUNK: start-end`); falls back to `"recursive"` without an LLM. | High-value documents with shifting topics. |
272
285
 
273
- Every chunk gets a stable id `{parent_id}_chunk_{n}_{content_hash}` plus `parent_id`, `prev_id` and `next_id` metadata. That's what makes re-ingestion idempotent and neighbour expansion possible.
286
+ `chunk_size` is a hard limit for `fixed` and `recursive`: a line or sentence longer than it is split further, so log files, one-record-per-line data and text without punctuation never end up as one giant chunk. Line breaks inside a chunk are kept. For Chinese, Japanese, Thai, Lao, Khmer and Myanmar each character counts as one unit, and `。!?` end sentences.
287
+
288
+ Every chunk gets a stable id `{parent_id}_chunk_{n}_{content_hash}` plus `parent_id`, `prev_id` and `next_id` metadata. That's what makes re-ingestion idempotent and neighbour expansion possible. Consecutive PDF pages and slides are linked too, so `neighbor_window` can follow text across a page break.
274
289
 
275
290
  ```python
276
291
  from raglib import ChunkSplitter, Document, MockLLMClient
@@ -290,7 +305,7 @@ for chunk in splitter.split(docs):
290
305
  - `fusion="relative"` *(default)* scores every candidate on **both** signals, min-max normalizes each, and blends them with `hybrid_alpha`. A chunk that is decisive in one signal (e.g. the only chunk containing `INV-2024-0042`) is never out-voted by chunks that are mediocre in both.
291
306
  - `fusion="rrf"` uses classic rank-only Reciprocal Rank Fusion.
292
307
 
293
- Tokenization is Unicode-aware, including combining marks, so Hindi, Bengali, Tamil, Arabic, Thai, Cyrillic and accented Latin all work for BM25.
308
+ Tokenization is Unicode-aware, including combining marks, so Hindi, Bengali, Tamil, Arabic, Cyrillic and accented Latin all work for BM25. Scripts written without spaces (Chinese, Japanese, Thai, Lao, Khmer, Myanmar) are indexed as overlapping character bigrams (`東京都` -> `東京`, `京都`), so keyword search works for them without a word segmenter.
294
309
 
295
310
  ```python
296
311
  from raglib import RAG
@@ -323,7 +338,7 @@ Select via `RAG(..., rag_type="<name>")` or import the class from `raglib`. Ever
323
338
  | `rag_type` | Class | What it actually does | LLM calls / query* | Best Use Case |
324
339
  | :--- | :--- | :--- | :--- | :--- |
325
340
  | **`"naive"`** | `NaiveRAG` | Retrieve -> generate | 1 | Baseline |
326
- | **`"advanced"`** *(default)* | `AdvancedRAG` | Hybrid retrieve -> rerank -> dedupe -> cited generate | 1 | Most production Q&A |
341
+ | **`"advanced"`** *(default)* | `AdvancedRAG` | Hybrid retrieve -> rerank (when `reranker` is set; default `"none"`) -> dedupe -> cited generate | 1 | Most production Q&A |
327
342
  | **`"hybrid"`** | `HybridRAG` | Forces BM25 + dense hybrid retrieval | 1 | Keyword-heavy corpora (IDs, codes, names) |
328
343
  | **`"hybrid_web"`** | `HybridRAG(include_web=True)` | Corpus + live web, fused | 1 | Private docs + fresh public info |
329
344
  | **`"corrective"`** | `CorrectiveRAG` | Batched relevance grading -> CORRECT: keep relevant sentence strips / INCORRECT: search / AMBIGUOUS: both | 2–4 | Corpora that may not contain the answer |
@@ -339,6 +354,19 @@ Select via `RAG(..., rag_type="<name>")` or import the class from `raglib`. Ever
339
354
 
340
355
  \* Excluding the optional rewrite/condense steps.
341
356
 
357
+ ### Counting and aggregate questions (`SQLTool`)
358
+
359
+ Retrieval answers from the top-k chunks, so a question like "how many engineers are based in Tokyo?" over a 5,000-row table cannot be counted correctly: the model only ever sees a few chunks. For tabular data, give the agent an `SQLTool`. The LLM writes one read-only `SELECT`, which SQLite runs over every row:
360
+
361
+ ```python
362
+ from raglib import RAG, SQLTool
363
+
364
+ rag = RAG("people.csv", llm="openai", rag_type="agentic", tools=[SQLTool.from_files("people.csv")])
365
+ print(rag.query("How many engineers are based in Tokyo?").answer)
366
+ ```
367
+
368
+ `SQLTool` loads `.csv`, `.tsv`, `.xlsx`, `.json` and `.jsonl` files (or `add_rows(table, header, rows)`) into a private in-memory SQLite database. An SQLite authorizer allows only reads, so writes, `ATTACH` and `PRAGMA` are refused. Queries time out after `timeout_seconds` (default 5) and results are capped at `max_rows`.
369
+
342
370
  **Web search is never used unless you configure it** (`web_search_provider=...`). The exceptions are `web` and `hybrid_web`, which default to DuckDuckGo. Corrective RAG without a web provider retries the corpus with a refined query instead.
343
371
 
344
372
  ---
@@ -542,10 +570,12 @@ If `embedding_llm` is omitted, raglib uses the chat provider's embeddings (OpenA
542
570
  ### Vector Stores (`vector_db`)
543
571
 
544
572
  - **`"memory"`** *(default)*: in-RAM cosine search (numpy-accelerated when installed), persisted with `rag.save()` / `rag.load()`.
573
+ - **`"qdrant"`**: Qdrant (`pip install raglib-py[qdrant]`). In-process by default; `vector_db_kwargs={"path": "./qdrant"}` persists to disk, `{"url": "http://localhost:6333", "api_key": ...}` uses a server or Qdrant Cloud. Filters run inside Qdrant.
574
+ - **`"pgvector"`**: PostgreSQL with the pgvector extension (`pip install raglib-py[pgvector]`), e.g. `vector_db_kwargs={"dsn": "postgresql://user:pass@host/db", "table_name": "docs"}`. Uses an HNSW cosine index when available; filters become parameterized SQL on a JSONB column.
545
575
  - **`"chroma"`**: ChromaDB in cosine space. Each `RAG` gets its **own collection** unless you name one, so instances never see each other's data. Use `{"persist_directory": ..., "collection_name": ...}` for a durable index or `{"host": ..., "port": ...}` for a Chroma server.
546
576
  - **Your own**: subclass `BaseVectorStore` (`upsert`, `query(filters=...)`, `delete`, `count`).
547
577
 
548
- Initialization errors are raised. Pass `vector_db_kwargs={"fallback_to_memory": True}` to opt into a fallback.
578
+ Initialization errors are raised. Pass `vector_db_kwargs={"fallback_to_memory": True}` to opt into a fallback. Every store refuses vectors of a different size than the ones it holds, so switching embedding models fails loudly instead of returning meaningless matches.
549
579
 
550
580
  ---
551
581
 
@@ -580,6 +610,10 @@ rag.query("What is our authentication service called?", session_id="user-42")
580
610
  rag.query("Which downstream services depend on it?", session_id="user-42")
581
611
  rag.reset_memory("user-42")
582
612
 
613
+ # Persist conversations across restarts and worker processes
614
+ from raglib import SQLiteConversationStore
615
+ rag = RAG("docs/", chat_llm="openai", memory=True, conversation_store=SQLiteConversationStore("chats.db", ttl_seconds=86400))
616
+
583
617
  # Streaming
584
618
  for token in rag.stream("Summarize the onboarding guide"):
585
619
  print(token, end="", flush=True)
@@ -590,7 +624,8 @@ for token in rag.stream("Summarize the onboarding guide"):
590
624
  # Tracing: every stage is timed; plug in LangSmith / OpenTelemetry / logging
591
625
  rag = RAG("docs/", chat_llm="openai", on_event=lambda e: print(e.stage, e.latency_ms, e.meta))
592
626
  result = rag.query("...")
593
- print(result.usage) # {"prompt_tokens": ..., "completion_tokens": ..., "latency_ms": ...}
627
+ print(result.usage) # answer call + totals over every LLM call of the query (see below)
628
+ print(result.metadata.get("degraded")) # optional steps that failed and fell back, if any
594
629
 
595
630
  rag.chat() # interactive terminal session with memory
596
631
  ```
@@ -652,7 +687,9 @@ result = pipeline.run("How does Corrective RAG handle low-scoring chunks?")
652
687
  print(result.answer, result.reasoning_trace)
653
688
  ```
654
689
 
655
- Subclass `BaseRAG` and override `retrieve(ctx)` (or `process_documents` / `generate` / `answer`) to build your own strategy. Condensation, memory, tracing, citations and streaming come for free.
690
+ Subclass `BaseRAG` and override `retrieve(ctx)` (or `process_documents` / `generate` / `answer`) to build your own strategy. Condensation, memory, tracing, citations, streaming, token usage and degradation reporting come for free. If you keep the default `retrieve`, it routes each query with `DecisionEngine` (corpus / web / both / none) and retries poor lexical matches with `Refiner`; the built-in strategies replace that step with their own.
691
+
692
+ Custom `BaseLLMClient` implementations can report token usage with `raglib.core.runtime.record_usage(prompt_tokens, completion_tokens)`, and custom steps can report fallbacks with `report_degraded("my_step", exc)` inside their `except` block.
656
693
 
657
694
  ---
658
695
 
@@ -669,8 +706,8 @@ from raglib import Document, GenerationResult, Citation, TraceEvent, QueryResult
669
706
  - `citations: List[Citation]` — `[n]` markers in the answer mapped to sources (`index`, `document_id`, `source`, `snippet`)
670
707
  - `reasoning_trace: List[str]` — human-readable pipeline steps
671
708
  - `trace_events: List[TraceEvent]` — `stage`, `latency_ms`, `meta`, `error` per stage
672
- - `usage: Dict` — prompt/completion tokens and total latency
673
- - `metadata: Dict` — pipeline name, standalone search query, session id, strategy details
709
+ - `usage: Dict` — `prompt_tokens` / `completion_tokens` of the answer call (`generation_usage_estimated` says whether they are the provider's counts or estimates), plus `llm_calls`, `total_prompt_tokens`, `total_completion_tokens`, `total_tokens` over every LLM call of the query (grading, routing, rewriting, ...), `usage_estimated`, and `latency_ms`
710
+ - `metadata: Dict` — pipeline name, standalone search query, session id, strategy details, and `degraded` (a list of `{component, error}` for optional steps that failed and fell back; with `RAG(strict=True)` those failures are raised instead)
674
711
  - **GraphRAG**: `raglib.graphrag.Entity`, `Relation`, `Community`
675
712
 
676
713
  ---
@@ -699,7 +736,8 @@ raglib graph papers/ --out graph.html
699
736
  | API keys | Read from env vars or arguments only, never logged. A chat key is only reused for embeddings from the same provider. | Keep keys in env vars or a secret manager. `.env.example` lists every variable. |
700
737
  | What leaves your machine | Questions, retrieved chunks and (with memory) chat history go to the LLM provider you chose. Chunks go to the embedding provider. Web search is off unless configured. | Use a local model (Ollama / LM Studio / vLLM) for confidential data. |
701
738
  | Logs | Questions, answers and document text are never logged at INFO or above. | Don't enable DEBUG logging in production if queries may contain personal data. |
702
- | User-supplied URLs | Private, loopback, link-local and metadata addresses are blocked (SSRF), redirects are re-checked, and responses are capped at 20 MB. | `allow_private_urls=True` only for trusted intranet sources. |
739
+ | User-supplied URLs | Private, loopback, link-local and metadata addresses are blocked (SSRF). The host is resolved once and the connection goes to the checked address, so DNS rebinding cannot reach internal services. Redirects are re-checked and responses are capped at 20 MB. With an `HTTPS_PROXY`, the proxy resolves hosts, so only the pre-check applies. | `allow_private_urls=True` only for trusted intranet sources. |
740
+ | `SQLTool` | Runs on a private in-memory copy of the tables; only read statements are authorized, one statement per call, with a timeout and a row cap. | Load only tables the agent may read. |
703
741
  | User-supplied file paths | `allowed_dirs=[...]` sandboxes file and folder sources (resolves `..` and symlinks). | Always set it when paths come from users. |
704
742
  | Prompt injection | Retrieved text is wrapped in `<source>` blocks with an instruction to treat it as data. | Treat answers as untrusted output; don't give agent tools destructive permissions. |
705
743
  | Multi-user | `session_id` isolates chat history. Documents are shared within one `RAG` instance. | Use one `RAG` per tenant, or `filters={"tenant": ...}` on every query. |
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "raglib-py"
7
- version = "2.0.3"
7
+ version = "2.1.0"
8
8
  description = "Modular Retrieval-Augmented Generation: hybrid search, reranking, CRAG, Self-RAG, agentic and GraphRAG pipelines"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -54,6 +54,8 @@ cohere = ["cohere>=5.0.0"]
54
54
  fast = ["numpy>=1.24", "tiktoken>=0.5.0"]
55
55
  # storage
56
56
  chroma = ["chromadb>=0.5.0"]
57
+ qdrant = ["qdrant-client>=1.10.0"]
58
+ pgvector = ["psycopg[binary]>=3.1"]
57
59
  graph = ["networkx>=3.0"]
58
60
  leiden = ["networkx>=3.0", "graspologic>=3.3"]
59
61
  neo4j = ["neo4j>=5.0", "networkx>=3.0"]
@@ -61,6 +63,7 @@ neo4j = ["neo4j>=5.0", "networkx>=3.0"]
61
63
  pdf = ["PyMuPDF>=1.23.0"]
62
64
  docx = ["python-docx>=1.0.0"]
63
65
  pptx = ["python-pptx>=0.6.21"]
66
+ xlsx = ["openpyxl>=3.1"]
64
67
  ocr = ["pytesseract>=0.3.10", "Pillow>=10.0.0"]
65
68
  # web search
66
69
  web = ["ddgs>=6.0.0"]
@@ -91,6 +94,7 @@ all = [
91
94
  "PyMuPDF>=1.23.0",
92
95
  "python-docx>=1.0.0",
93
96
  "python-pptx>=0.6.21",
97
+ "openpyxl>=3.1",
94
98
  "ddgs>=6.0.0",
95
99
  ]
96
100
  dev = [
@@ -100,6 +104,7 @@ dev = [
100
104
  "build>=1.0.0",
101
105
  "twine>=4.0.0",
102
106
  "networkx>=3.0",
107
+ "mypy>=1.8",
103
108
  ]
104
109
 
105
110
  [tool.hatch.build.targets.wheel]
@@ -113,6 +118,24 @@ include = [
113
118
  "pyproject.toml",
114
119
  ]
115
120
 
121
+ [tool.ruff]
122
+ target-version = "py39"
123
+ line-length = 130
124
+ extend-exclude = ["site", "dist"]
125
+
126
+ [tool.ruff.lint]
127
+ # pyflakes, pycodestyle errors, import sorting, bugbear-lite. Pyupgrade (UP) rules are off:
128
+ # typing.List/Optional are kept deliberately for Python 3.9 support.
129
+ select = ["E", "F", "I", "B006", "B008", "B904"]
130
+ ignore = ["E501", "E731", "E741", "E402"]
131
+
132
+ [tool.mypy]
133
+ python_version = "3.9"
134
+ ignore_missing_imports = true
135
+ warn_unused_ignores = false
136
+ no_implicit_optional = false
137
+ check_untyped_defs = false
138
+
116
139
  [tool.pytest.ini_options]
117
140
  markers = [
118
141
  "e2e: End-to-end tests for the raglib facade and pipelines",
@@ -24,16 +24,23 @@ from raglib.components import (
24
24
  Reranker,
25
25
  Retriever,
26
26
  RouterRetriever,
27
+ SQLiteConversationStore,
28
+ SQLTool,
27
29
  Tool,
28
30
  WebRetriever,
29
31
  )
30
32
  from raglib.core.base import BaseRAG
31
33
  from raglib.facade import RAG
32
- from raglib.quick import ask
33
- from raglib.graph_context import ConnectedNodeRef, GraphContextResult, GraphContextWindow, GraphNode
34
+ from raglib.graph_context import (
35
+ ConnectedNodeRef,
36
+ GraphContextResult,
37
+ GraphContextWindow,
38
+ GraphNode,
39
+ )
34
40
  from raglib.llm.base_client import BaseLLMClient, CachedLLMClient
35
41
  from raglib.llm.mock_client import MockLLMClient
36
42
  from raglib.loaders.chunk_splitter import ChunkSplitter
43
+ from raglib.quick import ask
37
44
  from raglib.rag_types import (
38
45
  AdvancedRAG,
39
46
  AgenticRAG,
@@ -49,7 +56,14 @@ from raglib.rag_types import (
49
56
  ToolAugmentedRAG,
50
57
  WebRAG,
51
58
  )
52
- from raglib.schemas import Citation, Document, GenerationResult, QueryResult, RetrievalContext, TraceEvent
59
+ from raglib.schemas import (
60
+ Citation,
61
+ Document,
62
+ GenerationResult,
63
+ QueryResult,
64
+ RetrievalContext,
65
+ TraceEvent,
66
+ )
53
67
 
54
68
  __all__ = [
55
69
  "RAG",
@@ -88,6 +102,8 @@ __all__ = [
88
102
  "ContextReducer",
89
103
  "Generator",
90
104
  "Tool",
105
+ "SQLTool",
106
+ "SQLiteConversationStore",
91
107
  "NaiveRAG",
92
108
  "AdvancedRAG",
93
109
  "CorrectiveRAG",
@@ -107,4 +123,4 @@ __all__ = [
107
123
  "GraphContextWindow",
108
124
  ]
109
125
 
110
- __version__ = "2.0.3"
126
+ __version__ = "2.1.0"