raglib-py 2.0.4__tar.gz → 2.2.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.
- {raglib_py-2.0.4 → raglib_py-2.2.0}/PKG-INFO +147 -47
- {raglib_py-2.0.4 → raglib_py-2.2.0}/README.md +136 -20
- {raglib_py-2.0.4 → raglib_py-2.2.0}/pyproject.toml +131 -119
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/__init__.py +134 -110
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/cli.py +22 -1
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/__init__.py +52 -49
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/decision.py +72 -71
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/generator.py +247 -208
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/grader.py +111 -108
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/hybrid_retriever.py +1 -1
- raglib_py-2.2.0/raglib/components/memory.py +274 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/multi_query_retriever.py +87 -56
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/planner.py +68 -67
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/query_expander.py +56 -51
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/query_rewriter.py +85 -84
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/refiner.py +42 -41
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/reranker.py +161 -160
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/retriever.py +53 -5
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/router_retriever.py +112 -107
- raglib_py-2.2.0/raglib/components/sql_tool.py +337 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/web_retriever.py +3 -2
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/constants.py +3 -1
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/core/base.py +408 -386
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/core/concurrency.py +5 -1
- raglib_py-2.2.0/raglib/core/parsing.py +121 -0
- raglib_py-2.2.0/raglib/core/runtime.py +123 -0
- raglib_py-2.2.0/raglib/core/text.py +199 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/embedding/base_embedding.py +12 -1
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/embedding/cached_embedding.py +11 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/embedding/embedding_factory.py +19 -4
- raglib_py-2.2.0/raglib/embedding/google_embedding.py +78 -0
- raglib_py-2.2.0/raglib/embedding/huggingface_embedding.py +62 -0
- raglib_py-2.2.0/raglib/embedding/ollama_embedding.py +59 -0
- raglib_py-2.2.0/raglib/embedding/openai_embedding.py +106 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/facade.py +1356 -1078
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graph_context/engine.py +1109 -1140
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/__init__.py +7 -1
- raglib_py-2.2.0/raglib/graphrag/background.py +182 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/extractor.py +21 -7
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/indexer.py +141 -37
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/search.py +8 -3
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/store/base.py +0 -3
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/store/neo4j_store.py +0 -2
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/store/networkx_store.py +264 -267
- raglib_py-2.2.0/raglib/llm/__init__.py +30 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/llm/base_client.py +37 -1
- raglib_py-2.2.0/raglib/llm/clients.py +714 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/llm/constants.py +40 -39
- raglib_py-2.2.0/raglib/llm/http.py +183 -0
- raglib_py-2.2.0/raglib/llm/langchain_adapter.py +290 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/llm/mock_client.py +218 -205
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/llm/provider_detector.py +23 -16
- raglib_py-2.2.0/raglib/llm/providers.py +555 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/llm/resilience.py +205 -195
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/__init__.py +12 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/chunk_splitter.py +124 -36
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/document_loader.py +73 -10
- raglib_py-2.2.0/raglib/loaders/html_text.py +147 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/pdf_loader.py +6 -3
- raglib_py-2.2.0/raglib/loaders/structured_loaders.py +253 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/text_loader.py +6 -1
- raglib_py-2.2.0/raglib/loaders/web_loader.py +236 -0
- raglib_py-2.2.0/raglib/providers/duckduckgo_provider.py +125 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/factory.py +4 -1
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/advanced_rag.py +5 -1
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/agentic_rag.py +14 -2
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/corrective_rag.py +224 -219
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/graph_rag.py +81 -68
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/self_rag.py +2 -5
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/tool_augmented_rag.py +46 -45
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vectorstores/__init__.py +17 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vectorstores/chroma_store.py +17 -6
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vectorstores/factory.py +65 -57
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vectorstores/in_memory_store.py +108 -4
- raglib_py-2.2.0/raglib/vectorstores/pgvector_store.py +245 -0
- raglib_py-2.2.0/raglib/vectorstores/qdrant_store.py +221 -0
- raglib_py-2.2.0/raglib/vision/anthropic_vision.py +41 -0
- raglib_py-2.2.0/raglib/vision/base_vision.py +27 -0
- raglib_py-2.2.0/raglib/vision/chat_vision.py +27 -0
- raglib_py-2.2.0/raglib/vision/google_vision.py +41 -0
- raglib_py-2.2.0/raglib/vision/openai_vision.py +41 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vision/vision_factory.py +2 -2
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/visualize.py +299 -300
- raglib_py-2.0.4/raglib/components/memory.py +0 -121
- raglib_py-2.0.4/raglib/core/parsing.py +0 -67
- raglib_py-2.0.4/raglib/core/text.py +0 -97
- raglib_py-2.0.4/raglib/embedding/google_embedding.py +0 -53
- raglib_py-2.0.4/raglib/embedding/huggingface_embedding.py +0 -56
- raglib_py-2.0.4/raglib/embedding/ollama_embedding.py +0 -59
- raglib_py-2.0.4/raglib/embedding/openai_embedding.py +0 -91
- raglib_py-2.0.4/raglib/llm/__init__.py +0 -6
- raglib_py-2.0.4/raglib/llm/langchain_adapter.py +0 -324
- raglib_py-2.0.4/raglib/llm/providers.py +0 -208
- raglib_py-2.0.4/raglib/loaders/web_loader.py +0 -155
- raglib_py-2.0.4/raglib/providers/duckduckgo_provider.py +0 -280
- raglib_py-2.0.4/raglib/vision/anthropic_vision.py +0 -82
- raglib_py-2.0.4/raglib/vision/base_vision.py +0 -16
- raglib_py-2.0.4/raglib/vision/google_vision.py +0 -75
- raglib_py-2.0.4/raglib/vision/openai_vision.py +0 -77
- raglib_py-2.0.4/site/README.md +0 -18
- raglib_py-2.0.4/site/node_modules/@babel/code-frame/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/code-frame/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/compat-data/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/compat-data/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/core/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/core/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/generator/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/generator/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-compilation-targets/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-compilation-targets/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-globals/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-globals/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-module-imports/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-module-imports/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-module-transforms/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-module-transforms/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-plugin-utils/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-plugin-utils/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-string-parser/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-string-parser/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-validator-identifier/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-validator-identifier/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helper-validator-option/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/helper-validator-option/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/helpers/LICENSE +0 -23
- raglib_py-2.0.4/site/node_modules/@babel/helpers/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/parser/LICENSE +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/parser/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/plugin-transform-react-jsx-self/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/plugin-transform-react-jsx-self/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/plugin-transform-react-jsx-source/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/plugin-transform-react-jsx-source/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/template/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/template/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/traverse/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/traverse/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@babel/types/LICENSE +0 -22
- raglib_py-2.0.4/site/node_modules/@babel/types/README.md +0 -19
- raglib_py-2.0.4/site/node_modules/@esbuild/win32-x64/README.md +0 -3
- raglib_py-2.0.4/site/node_modules/@jridgewell/gen-mapping/LICENSE +0 -19
- raglib_py-2.0.4/site/node_modules/@jridgewell/gen-mapping/README.md +0 -227
- raglib_py-2.0.4/site/node_modules/@jridgewell/remapping/LICENSE +0 -19
- raglib_py-2.0.4/site/node_modules/@jridgewell/remapping/README.md +0 -218
- raglib_py-2.0.4/site/node_modules/@jridgewell/resolve-uri/LICENSE +0 -19
- raglib_py-2.0.4/site/node_modules/@jridgewell/resolve-uri/README.md +0 -40
- raglib_py-2.0.4/site/node_modules/@jridgewell/sourcemap-codec/LICENSE +0 -19
- raglib_py-2.0.4/site/node_modules/@jridgewell/sourcemap-codec/README.md +0 -264
- raglib_py-2.0.4/site/node_modules/@jridgewell/trace-mapping/LICENSE +0 -19
- raglib_py-2.0.4/site/node_modules/@jridgewell/trace-mapping/README.md +0 -348
- raglib_py-2.0.4/site/node_modules/@rolldown/pluginutils/LICENSE +0 -25
- raglib_py-2.0.4/site/node_modules/@rollup/rollup-win32-x64-gnu/README.md +0 -3
- raglib_py-2.0.4/site/node_modules/@rollup/rollup-win32-x64-msvc/README.md +0 -3
- raglib_py-2.0.4/site/node_modules/@types/babel__core/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/babel__core/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@types/babel__generator/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/babel__generator/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@types/babel__template/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/babel__template/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@types/babel__traverse/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/babel__traverse/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@types/estree/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/estree/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@types/prop-types/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/prop-types/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@types/react/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/react/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@types/react-dom/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@types/react-dom/README.md +0 -15
- raglib_py-2.0.4/site/node_modules/@vitejs/plugin-react/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/@vitejs/plugin-react/README.md +0 -142
- raglib_py-2.0.4/site/node_modules/baseline-browser-mapping/README.md +0 -545
- raglib_py-2.0.4/site/node_modules/browserslist/LICENSE +0 -20
- raglib_py-2.0.4/site/node_modules/browserslist/README.md +0 -66
- raglib_py-2.0.4/site/node_modules/caniuse-lite/LICENSE +0 -395
- raglib_py-2.0.4/site/node_modules/caniuse-lite/README.md +0 -3
- raglib_py-2.0.4/site/node_modules/convert-source-map/LICENSE +0 -23
- raglib_py-2.0.4/site/node_modules/convert-source-map/README.md +0 -206
- raglib_py-2.0.4/site/node_modules/csstype/LICENSE +0 -19
- raglib_py-2.0.4/site/node_modules/csstype/README.md +0 -291
- raglib_py-2.0.4/site/node_modules/debug/LICENSE +0 -20
- raglib_py-2.0.4/site/node_modules/debug/README.md +0 -481
- raglib_py-2.0.4/site/node_modules/electron-to-chromium/LICENSE +0 -5
- raglib_py-2.0.4/site/node_modules/electron-to-chromium/README.md +0 -186
- raglib_py-2.0.4/site/node_modules/esbuild/README.md +0 -3
- raglib_py-2.0.4/site/node_modules/gensync/LICENSE +0 -7
- raglib_py-2.0.4/site/node_modules/gensync/README.md +0 -196
- raglib_py-2.0.4/site/node_modules/js-tokens/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/js-tokens/README.md +0 -240
- raglib_py-2.0.4/site/node_modules/jsesc/README.md +0 -422
- raglib_py-2.0.4/site/node_modules/json5/README.md +0 -282
- raglib_py-2.0.4/site/node_modules/loose-envify/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/loose-envify/README.md +0 -45
- raglib_py-2.0.4/site/node_modules/lru-cache/LICENSE +0 -15
- raglib_py-2.0.4/site/node_modules/lru-cache/README.md +0 -166
- raglib_py-2.0.4/site/node_modules/nanoid/LICENSE +0 -20
- raglib_py-2.0.4/site/node_modules/nanoid/README.md +0 -39
- raglib_py-2.0.4/site/node_modules/node-releases/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/node-releases/README.md +0 -32
- raglib_py-2.0.4/site/node_modules/picocolors/LICENSE +0 -15
- raglib_py-2.0.4/site/node_modules/picocolors/README.md +0 -21
- raglib_py-2.0.4/site/node_modules/postcss/LICENSE +0 -20
- raglib_py-2.0.4/site/node_modules/postcss/README.md +0 -27
- raglib_py-2.0.4/site/node_modules/react/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/react/README.md +0 -37
- raglib_py-2.0.4/site/node_modules/react-dom/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/react-dom/README.md +0 -60
- raglib_py-2.0.4/site/node_modules/react-refresh/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/react-refresh/README.md +0 -5
- raglib_py-2.0.4/site/node_modules/rollup/README.md +0 -134
- raglib_py-2.0.4/site/node_modules/scheduler/LICENSE +0 -21
- raglib_py-2.0.4/site/node_modules/scheduler/README.md +0 -9
- raglib_py-2.0.4/site/node_modules/semver/LICENSE +0 -15
- raglib_py-2.0.4/site/node_modules/semver/README.md +0 -443
- raglib_py-2.0.4/site/node_modules/source-map-js/LICENSE +0 -28
- raglib_py-2.0.4/site/node_modules/source-map-js/README.md +0 -765
- raglib_py-2.0.4/site/node_modules/typescript/README.md +0 -50
- raglib_py-2.0.4/site/node_modules/update-browserslist-db/LICENSE +0 -20
- raglib_py-2.0.4/site/node_modules/update-browserslist-db/README.md +0 -41
- raglib_py-2.0.4/site/node_modules/vite/README.md +0 -20
- raglib_py-2.0.4/site/node_modules/yallist/LICENSE +0 -15
- raglib_py-2.0.4/site/node_modules/yallist/README.md +0 -204
- {raglib_py-2.0.4 → raglib_py-2.2.0}/.gitignore +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/LICENSE +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/__main__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/bm25.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/context_reducer.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/deduplicator.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/evaluator.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/multi_hop_retriever.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/reflection.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/components/tools.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/core/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/core/fusion.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/core/intents.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/core/tracing.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/embedding/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/embedding/mock_embedding.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/eval/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graph_context/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graph_context/schemas.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/communities.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/schemas.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/graphrag/store/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/exceptions.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/pptx_loader.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/loaders/word_loader.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/preprocessing/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/preprocessing/chunk_splitter.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/base_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/bing_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/brave_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/exa_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/google_cse_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/searxng_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/serpapi_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/providers/tavily_provider.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/quick.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/hybrid_rag.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/memory_rag.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/multi_hop_rag.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/multi_query_rag.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/naive_rag.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/routing_rag.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/rag_types/web_rag.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/schemas.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/session/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/session/interactive.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vectorstores/base_store.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vision/__init__.py +0 -0
- {raglib_py-2.0.4 → raglib_py-2.2.0}/raglib/vision/mock_vision.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: raglib-py
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.2.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
|
|
@@ -44,36 +44,23 @@ Requires-Python: >=3.9
|
|
|
44
44
|
Provides-Extra: all
|
|
45
45
|
Requires-Dist: chromadb>=0.5.0; extra == 'all'
|
|
46
46
|
Requires-Dist: ddgs>=6.0.0; extra == 'all'
|
|
47
|
-
Requires-Dist: langchain-anthropic>=0.1.0; extra == 'all'
|
|
48
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'all'
|
|
49
|
-
Requires-Dist: langchain-google-genai>=1.0.0; extra == 'all'
|
|
50
|
-
Requires-Dist: langchain-groq>=0.1.0; extra == 'all'
|
|
51
|
-
Requires-Dist: langchain-huggingface>=0.0.3; extra == 'all'
|
|
52
|
-
Requires-Dist: langchain-ollama>=0.1.0; extra == 'all'
|
|
53
|
-
Requires-Dist: langchain-openai>=0.1.0; extra == 'all'
|
|
54
47
|
Requires-Dist: networkx>=3.0; extra == 'all'
|
|
55
48
|
Requires-Dist: numpy>=1.24; extra == 'all'
|
|
49
|
+
Requires-Dist: openpyxl>=3.1; extra == 'all'
|
|
56
50
|
Requires-Dist: pymupdf>=1.23.0; extra == 'all'
|
|
57
51
|
Requires-Dist: python-docx>=1.0.0; extra == 'all'
|
|
58
52
|
Requires-Dist: python-pptx>=0.6.21; extra == 'all'
|
|
59
53
|
Requires-Dist: sentence-transformers>=2.6.0; extra == 'all'
|
|
60
54
|
Requires-Dist: tiktoken>=0.5.0; extra == 'all'
|
|
61
55
|
Provides-Extra: all-llm
|
|
62
|
-
Requires-Dist: langchain-anthropic>=0.1.0; extra == 'all-llm'
|
|
63
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'all-llm'
|
|
64
|
-
Requires-Dist: langchain-google-genai>=1.0.0; extra == 'all-llm'
|
|
65
|
-
Requires-Dist: langchain-groq>=0.1.0; extra == 'all-llm'
|
|
66
|
-
Requires-Dist: langchain-ollama>=0.1.0; extra == 'all-llm'
|
|
67
|
-
Requires-Dist: langchain-openai>=0.1.0; extra == 'all-llm'
|
|
68
56
|
Provides-Extra: anthropic
|
|
69
|
-
Requires-Dist: langchain-anthropic>=0.1.0; extra == 'anthropic'
|
|
70
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'anthropic'
|
|
71
57
|
Provides-Extra: chroma
|
|
72
58
|
Requires-Dist: chromadb>=0.5.0; extra == 'chroma'
|
|
73
59
|
Provides-Extra: cohere
|
|
74
60
|
Requires-Dist: cohere>=5.0.0; extra == 'cohere'
|
|
75
61
|
Provides-Extra: dev
|
|
76
62
|
Requires-Dist: build>=1.0.0; extra == 'dev'
|
|
63
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
77
64
|
Requires-Dist: networkx>=3.0; extra == 'dev'
|
|
78
65
|
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
79
66
|
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
@@ -85,16 +72,13 @@ Provides-Extra: fast
|
|
|
85
72
|
Requires-Dist: numpy>=1.24; extra == 'fast'
|
|
86
73
|
Requires-Dist: tiktoken>=0.5.0; extra == 'fast'
|
|
87
74
|
Provides-Extra: google
|
|
88
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'google'
|
|
89
|
-
Requires-Dist: langchain-google-genai>=1.0.0; extra == 'google'
|
|
90
75
|
Provides-Extra: graph
|
|
91
76
|
Requires-Dist: networkx>=3.0; extra == 'graph'
|
|
92
77
|
Provides-Extra: groq
|
|
93
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'groq'
|
|
94
|
-
Requires-Dist: langchain-groq>=0.1.0; extra == 'groq'
|
|
95
78
|
Provides-Extra: hf
|
|
96
|
-
Requires-Dist: langchain-huggingface>=0.0.3; extra == 'hf'
|
|
97
79
|
Requires-Dist: sentence-transformers>=2.6.0; extra == 'hf'
|
|
80
|
+
Provides-Extra: langchain
|
|
81
|
+
Requires-Dist: langchain-core>=0.2.0; extra == 'langchain'
|
|
98
82
|
Provides-Extra: leiden
|
|
99
83
|
Requires-Dist: graspologic>=3.3; extra == 'leiden'
|
|
100
84
|
Requires-Dist: networkx>=3.0; extra == 'leiden'
|
|
@@ -105,18 +89,16 @@ Provides-Extra: ocr
|
|
|
105
89
|
Requires-Dist: pillow>=10.0.0; extra == 'ocr'
|
|
106
90
|
Requires-Dist: pytesseract>=0.3.10; extra == 'ocr'
|
|
107
91
|
Provides-Extra: ollama
|
|
108
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'ollama'
|
|
109
|
-
Requires-Dist: langchain-ollama>=0.1.0; extra == 'ollama'
|
|
110
92
|
Provides-Extra: openai
|
|
111
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'openai'
|
|
112
|
-
Requires-Dist: langchain-openai>=0.1.0; extra == 'openai'
|
|
113
93
|
Provides-Extra: openrouter
|
|
114
|
-
Requires-Dist: langchain-core>=0.2.0; extra == 'openrouter'
|
|
115
|
-
Requires-Dist: langchain-openai>=0.1.0; extra == 'openrouter'
|
|
116
94
|
Provides-Extra: pdf
|
|
117
95
|
Requires-Dist: pymupdf>=1.23.0; extra == 'pdf'
|
|
96
|
+
Provides-Extra: pgvector
|
|
97
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == 'pgvector'
|
|
118
98
|
Provides-Extra: pptx
|
|
119
99
|
Requires-Dist: python-pptx>=0.6.21; extra == 'pptx'
|
|
100
|
+
Provides-Extra: qdrant
|
|
101
|
+
Requires-Dist: qdrant-client>=1.10.0; extra == 'qdrant'
|
|
120
102
|
Provides-Extra: rerank
|
|
121
103
|
Requires-Dist: sentence-transformers>=2.6.0; extra == 'rerank'
|
|
122
104
|
Provides-Extra: serpapi
|
|
@@ -125,6 +107,8 @@ Provides-Extra: tavily
|
|
|
125
107
|
Requires-Dist: tavily-python>=0.2.0; extra == 'tavily'
|
|
126
108
|
Provides-Extra: web
|
|
127
109
|
Requires-Dist: ddgs>=6.0.0; extra == 'web'
|
|
110
|
+
Provides-Extra: xlsx
|
|
111
|
+
Requires-Dist: openpyxl>=3.1; extra == 'xlsx'
|
|
128
112
|
Description-Content-Type: text/markdown
|
|
129
113
|
|
|
130
114
|
# raglib-py (v2.0.0) — Complete Documentation & Developer Guide
|
|
@@ -176,14 +160,18 @@ pip install raglib-py
|
|
|
176
160
|
pip install "raglib-py[all]"
|
|
177
161
|
|
|
178
162
|
# Or pick what you need:
|
|
179
|
-
|
|
163
|
+
# Chat and embedding providers (OpenAI, Anthropic, Gemini, OpenRouter, Groq, Ollama, ...) need no extra:
|
|
164
|
+
# raglib calls their HTTP APIs directly. The [openai], [anthropic], ... extras still install (as no-ops).
|
|
180
165
|
pip install "raglib-py[hf]" # local HuggingFace / SentenceTransformers embeddings
|
|
181
166
|
pip install "raglib-py[rerank]" # cross-encoder reranker (bge-reranker)
|
|
182
167
|
pip install "raglib-py[fast]" # numpy vector math + tiktoken token counting
|
|
183
168
|
pip install "raglib-py[chroma]" # persistent ChromaDB vector store
|
|
169
|
+
pip install "raglib-py[qdrant]" # Qdrant vector store (in-process, on-disk or server)
|
|
170
|
+
pip install "raglib-py[pgvector]" # PostgreSQL + pgvector vector store
|
|
184
171
|
pip install "raglib-py[graph]" # GraphRAG community detection (networkx)
|
|
185
172
|
pip install "raglib-py[neo4j]" # Neo4j graph store
|
|
186
173
|
pip install "raglib-py[pdf,docx,pptx]" # document loaders
|
|
174
|
+
pip install "raglib-py[xlsx]" # Excel workbooks (loader + SQLTool)
|
|
187
175
|
pip install "raglib-py[web]" # DuckDuckGo web search
|
|
188
176
|
pip install "raglib-py[tavily,serpapi]" # Tavily & SerpAPI SDKs
|
|
189
177
|
```
|
|
@@ -316,13 +304,15 @@ rag = RAG(
|
|
|
316
304
|
offline=None, # True -> explicit mock models (or RAGLIB_OFFLINE=1)
|
|
317
305
|
llm_cache=True, # LRU cache for identical (system, prompt) LLM calls
|
|
318
306
|
llm_timeout=60.0, llm_max_retries=2, # per-call timeout + exponential-backoff retries
|
|
307
|
+
llm_temperature=0.0, # sampling temperature for models built from a provider name
|
|
308
|
+
llm_max_tokens=None, # cap on answer length (mapped to each provider's parameter)
|
|
319
309
|
# ---- pipeline
|
|
320
310
|
rag_type="advanced", # One of the 14 RAG architectures
|
|
321
311
|
top_k=5, # Documents passed to generation
|
|
322
312
|
max_context_tokens=3000, # Generation context budget (tiktoken when installed)
|
|
323
313
|
rewrite_query=False, # LLM query rewriting before retrieval
|
|
324
314
|
# ---- chunking
|
|
325
|
-
chunk_size=400, chunk_overlap=50, # words
|
|
315
|
+
chunk_size=400, chunk_overlap=50, # words (each Chinese/Japanese/Thai character counts as one); a hard limit
|
|
326
316
|
chunking_strategy="fixed", # "fixed" | "recursive" | "llm"
|
|
327
317
|
# ---- retrieval
|
|
328
318
|
retrieval_mode=None, # "hybrid" (default with embeddings) | "dense" | "sparse"
|
|
@@ -333,11 +323,12 @@ rag = RAG(
|
|
|
333
323
|
neighbor_window=0, # small-to-big: attach N neighbouring chunks to each hit
|
|
334
324
|
reranker="none", # "none" | "cross_encoder" | "cohere" | "llm"
|
|
335
325
|
reranker_model=None, reranker_api_key=None,
|
|
336
|
-
vector_db=None, # "memory" (default) | "chroma" | BaseVectorStore
|
|
326
|
+
vector_db=None, # "memory" (default) | "chroma" | "qdrant" | "pgvector" | BaseVectorStore
|
|
337
327
|
vector_db_kwargs=None, # e.g. {"persist_directory": "...", "collection_name": "...", "host": ...}
|
|
338
328
|
# ---- memory
|
|
339
329
|
memory=None, # True to enable conversation memory for any rag_type
|
|
340
330
|
max_history_turns=10, max_history_tokens=1200,
|
|
331
|
+
conversation_store=None, # e.g. SQLiteConversationStore("chats.db") to persist sessions
|
|
341
332
|
# ---- web search (OFF unless configured)
|
|
342
333
|
web_search_provider=None, # "duckduckgo" | "local" | "tavily" | "serpapi" | "brave" | "bing" | "google_cse" | "exa" | "searxng"
|
|
343
334
|
web_search_api_key=None, web_search_base_url=None, web_search_cse_id=None,
|
|
@@ -347,7 +338,8 @@ rag = RAG(
|
|
|
347
338
|
graph_store=None, # "networkx" (default) | "neo4j" | BaseGraphStore
|
|
348
339
|
graph_kwargs=None, # see section 8
|
|
349
340
|
# ---- agents & observability
|
|
350
|
-
tools=None, # [Tool(...)] for rag_type="agentic"
|
|
341
|
+
tools=None, # [Tool(...), SQLTool(...)] for rag_type="agentic"
|
|
342
|
+
strict=False, # True: raise when an optional step fails instead of degrading
|
|
351
343
|
on_event=None, # callback(TraceEvent) for every pipeline stage
|
|
352
344
|
output_dir=None, # write each query result as JSON
|
|
353
345
|
**rag_type_kwargs, # forwarded to the orchestrator (e.g. max_hops=3, search_mode="global")
|
|
@@ -363,7 +355,7 @@ rag = RAG(
|
|
|
363
355
|
| `await rag.aquery(question, ...)` | Async query. |
|
|
364
356
|
| `rag.add(source) -> int` | Idempotent upsert: unchanged documents are skipped, changed ones replace their old chunks. Returns new chunks indexed. |
|
|
365
357
|
| `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. |
|
|
358
|
+
| `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
359
|
| `rag.reset_memory(session_id=None)` | Clear one conversation (or all). |
|
|
368
360
|
| `rag.evaluate(dataset, judge_llm=None)` | Retrieval + answer-quality metrics (section 13). |
|
|
369
361
|
| `rag.rebuild_graph_communities()` | Re-cluster the knowledge graph and refresh changed community reports. |
|
|
@@ -382,12 +374,18 @@ rag = RAG(
|
|
|
382
374
|
| **PDF file** (`.pdf`) | `"report.pdf"` | `PDFLoader` (one document per page; scanned pages via `vision_llm` OCR, otherwise skipped with a warning) |
|
|
383
375
|
| **Word file** (`.docx`) | `"spec.docx"` | `WordLoader` |
|
|
384
376
|
| **PowerPoint** (`.pptx`) | `"slides.pptx"` | `PPTXLoader` (one document per slide) |
|
|
385
|
-
| **Text / Markdown** (`.txt`, `.md
|
|
386
|
-
| **
|
|
377
|
+
| **Text / Markdown** (`.txt`, `.md`, `.rst`, `.log`, ...) | `"notes.md"` | `TextLoader` |
|
|
378
|
+
| **Source code & config** (`.py`, `.js`, `.ts`, `.java`, `.go`, `.sql`, `.yaml`, `.toml`, ...) | `"src/"` | `TextLoader` |
|
|
379
|
+
| **HTML file** (`.html`, `.htm`) | `"page.html"` | `HTMLFileLoader` (headings, lists and tables kept; nav/footer dropped; title in metadata) |
|
|
380
|
+
| **CSV / TSV** | `"people.csv"` | `CSVLoader` (one `column: value; ...` line per row) |
|
|
381
|
+
| **JSON / JSONL** | `"items.jsonl"` | `JSONLoader` (one line per record; other JSON pretty-printed) |
|
|
382
|
+
| **Excel** (`.xlsx`) | `"sales.xlsx"` | `XLSXLoader` (one document per sheet; `pip install raglib-py[xlsx]`) |
|
|
383
|
+
| **EPUB** (`.epub`) | `"book.epub"` | `EPUBLoader` (one document per chapter, in reading order) |
|
|
384
|
+
| **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
385
|
| **Raw text string** | `"RAG grounds LLM outputs."` | Wrapped directly as a `Document` (content-hash id) |
|
|
388
386
|
| **List of mixed sources** | `["a.pdf", "https://...", "raw note"]` | Each item is routed to its matching loader |
|
|
389
387
|
|
|
390
|
-
> **Safety Note:** If a string looks like a file path (
|
|
388
|
+
> **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
389
|
|
|
392
390
|
---
|
|
393
391
|
|
|
@@ -399,7 +397,9 @@ rag = RAG(
|
|
|
399
397
|
| **`"recursive"`** | `"recursive_character"` | Splits along structural separators (`"\n\n"`, `"\n"`, `". "`, ... `""`) to keep paragraphs together, then applies overlap. | Markdown, structured reports. |
|
|
400
398
|
| **`"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
399
|
|
|
402
|
-
|
|
400
|
+
`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.
|
|
401
|
+
|
|
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. Consecutive PDF pages and slides are linked too, so `neighbor_window` can follow text across a page break.
|
|
403
403
|
|
|
404
404
|
```python
|
|
405
405
|
from raglib import ChunkSplitter, Document, MockLLMClient
|
|
@@ -419,7 +419,7 @@ for chunk in splitter.split(docs):
|
|
|
419
419
|
- `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
420
|
- `fusion="rrf"` uses classic rank-only Reciprocal Rank Fusion.
|
|
421
421
|
|
|
422
|
-
Tokenization is Unicode-aware, including combining marks, so Hindi, Bengali, Tamil, Arabic,
|
|
422
|
+
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
423
|
|
|
424
424
|
```python
|
|
425
425
|
from raglib import RAG
|
|
@@ -452,7 +452,7 @@ Select via `RAG(..., rag_type="<name>")` or import the class from `raglib`. Ever
|
|
|
452
452
|
| `rag_type` | Class | What it actually does | LLM calls / query* | Best Use Case |
|
|
453
453
|
| :--- | :--- | :--- | :--- | :--- |
|
|
454
454
|
| **`"naive"`** | `NaiveRAG` | Retrieve -> generate | 1 | Baseline |
|
|
455
|
-
| **`"advanced"`** *(default)* | `AdvancedRAG` | Hybrid retrieve -> rerank -> dedupe -> cited generate | 1 | Most production Q&A |
|
|
455
|
+
| **`"advanced"`** *(default)* | `AdvancedRAG` | Hybrid retrieve -> rerank (when `reranker` is set; default `"none"`) -> dedupe -> cited generate | 1 | Most production Q&A |
|
|
456
456
|
| **`"hybrid"`** | `HybridRAG` | Forces BM25 + dense hybrid retrieval | 1 | Keyword-heavy corpora (IDs, codes, names) |
|
|
457
457
|
| **`"hybrid_web"`** | `HybridRAG(include_web=True)` | Corpus + live web, fused | 1 | Private docs + fresh public info |
|
|
458
458
|
| **`"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 +468,19 @@ Select via `RAG(..., rag_type="<name>")` or import the class from `raglib`. Ever
|
|
|
468
468
|
|
|
469
469
|
\* Excluding the optional rewrite/condense steps.
|
|
470
470
|
|
|
471
|
+
### Counting and aggregate questions (`SQLTool`)
|
|
472
|
+
|
|
473
|
+
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:
|
|
474
|
+
|
|
475
|
+
```python
|
|
476
|
+
from raglib import RAG, SQLTool
|
|
477
|
+
|
|
478
|
+
rag = RAG("people.csv", llm="openai", rag_type="agentic", tools=[SQLTool.from_files("people.csv")])
|
|
479
|
+
print(rag.query("How many engineers are based in Tokyo?").answer)
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
`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`.
|
|
483
|
+
|
|
471
484
|
**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
485
|
|
|
473
486
|
---
|
|
@@ -508,6 +521,14 @@ rag.save("./graph_index") # graph + extraction cache + vectors
|
|
|
508
521
|
|
|
509
522
|
Neo4j: `RAG(..., rag_type="graph", graph_store="neo4j", graph_kwargs={"store_options": {"uri": "bolt://localhost:7687", "user": "neo4j", "password": "...", "namespace": "papers"}})`.
|
|
510
523
|
|
|
524
|
+
**Indexing cost.** Building the graph takes one LLM call per chunk, plus one per community report. That is thousands of calls for a few hundred long documents, and indexing is the dominant GraphRAG cost. Use a cheaper or faster model for it with `graph_llm`; answers still use `llm`:
|
|
525
|
+
|
|
526
|
+
```python
|
|
527
|
+
rag = RAG("docs/", rag_type="graph", llm="openai/gpt-4.1", graph_llm="openai/gpt-4.1-nano")
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
`graph_llm` builds the graph (entity extraction, community reports, the global-search map step). Its key comes from `chat_api_key` only when it is the same provider, otherwise from its environment variable. With a reasoning model, turning thinking off for extraction is about 10× faster (see *Custom Providers*, `extra_body`).
|
|
531
|
+
|
|
511
532
|
To give **agentic** or **routing** pipelines a `graph_search` tool / route, pass `enable_graph=True`.
|
|
512
533
|
|
|
513
534
|
---
|
|
@@ -628,11 +649,13 @@ Hosted OpenAI-compatible APIs only need `pip install "raglib-py[openai]"`.
|
|
|
628
649
|
| **xAI Grok** | `"xai"` / `"grok"` | `grok-3-mini` | `XAI_API_KEY` | – |
|
|
629
650
|
| **Perplexity** | `"perplexity"` | `sonar` | `PERPLEXITY_API_KEY` | – |
|
|
630
651
|
| **Cerebras** | `"cerebras"` | `llama-3.3-70b` | `CEREBRAS_API_KEY` | – |
|
|
652
|
+
| **NVIDIA NIM** (build.nvidia.com or self-hosted via `NVIDIA_BASE_URL`) | `"nvidia"` / `"nim"` | `nvidia/nemotron-3.5-lightning-30b-a3b` | `NVIDIA_API_KEY` | yes (`nvidia/nemotron-3-embed-1b`); OCR with `nvidia/nemotron-3.5-super-vl-120b-a12b` |
|
|
631
653
|
| **Azure OpenAI** | `"azure/<deployment>"` | – | `AZURE_OPENAI_API_KEY` + `AZURE_OPENAI_ENDPOINT` | yes (deployment) |
|
|
632
654
|
| **Ollama** (local) | `"ollama"` | `llama3.1` | – | yes |
|
|
633
655
|
| **LM Studio** (local) | `"lmstudio/<model>"` | – | – | with `embedding_model` |
|
|
634
656
|
| **vLLM** (self-hosted) | `"vllm/<model>"` + `chat_base_url` | – | – | with `embedding_model` |
|
|
635
657
|
| **Any OpenAI-compatible API** | `"openai_compatible/<model>"` + `chat_base_url` | – | `OPENAI_COMPATIBLE_API_KEY` | with `embedding_model` |
|
|
658
|
+
| **Your own provider** (`register_provider` / JSON file) | `"<id>/<model>"` | first listed model | your choice | with `embedding_model` |
|
|
636
659
|
| **Any LangChain chat model / `BaseLLMClient`** | the object | – | – | – |
|
|
637
660
|
| **Mock (offline)** | `"mock"` or `offline=True` | templated | – | mock |
|
|
638
661
|
|
|
@@ -652,6 +675,73 @@ rag = RAG("docs/", llm="vllm/Qwen/Qwen2.5-7B-Instruct", chat_base_url="http://gp
|
|
|
652
675
|
|
|
653
676
|
All provider calls get a timeout (`llm_timeout`), retries with jittered exponential backoff on rate limits / 5xx (`llm_max_retries`) and an LRU response cache (`llm_cache`).
|
|
654
677
|
|
|
678
|
+
raglib needs no SDK and no LangChain for any of these providers. `raglib.llm.clients` speaks the three wire protocols directly with the Python standard library: **OpenAI Chat Completions** (OpenAI, Azure, Groq, Ollama, OpenRouter and every other compatible API), **Anthropic Messages** and **Gemini `generateContent`**, including SSE streaming, JSON mode and real token usage. Build one directly with `from raglib.llm import build_chat_client; llm = build_chat_client("anthropic")`. A LangChain chat model you already have still works: pass it as `chat_llm=` and raglib wraps it with its retries and usage tracking.
|
|
679
|
+
|
|
680
|
+
### Custom Providers (any third-party or self-hosted API)
|
|
681
|
+
|
|
682
|
+
Register any provider that speaks one of the three supported APIs (`openai` Chat Completions, `anthropic` Messages, `gemini` generateContent), then use it like a built-in one:
|
|
683
|
+
|
|
684
|
+
```python
|
|
685
|
+
from raglib import RAG, register_provider
|
|
686
|
+
|
|
687
|
+
register_provider(
|
|
688
|
+
"myprovider", # lowercase letters, numbers, - or _
|
|
689
|
+
name="My AI Provider", # shown by `raglib providers`
|
|
690
|
+
api="openai", # "openai" | "anthropic" | "gemini"
|
|
691
|
+
base_url="https://api.myprovider.com/v1",
|
|
692
|
+
api_key="{env:MYPROVIDER_API_KEY}", # optional; leave out when auth is in headers
|
|
693
|
+
headers={"X-Team": "{env:MY_TEAM_ID}"}, # optional extra headers ({env:NAME} is expanded)
|
|
694
|
+
models=[
|
|
695
|
+
{"id": "model-id", "name": "Display Name"},
|
|
696
|
+
{"id": "model-r1", "name": "Reasoner", "reasoning": True},
|
|
697
|
+
{"id": "model-vl", "name": "Vision", "image": True},
|
|
698
|
+
],
|
|
699
|
+
embedding_model="embed-v1", # optional: semantic search through the same provider
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
rag = RAG("docs/", llm="myprovider/model-id") # or llm="myprovider" for the first listed model
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
| Model flag | Effect |
|
|
706
|
+
| :--- | :--- |
|
|
707
|
+
| `reasoning: true` | No `temperature` is sent (many reasoning endpoints reject it). A leading `<think>...</think>` block is removed from answers and streams for every model, so citations and JSON parsing keep working. |
|
|
708
|
+
| `image: true` | The model can read scanned PDF pages: it is used for OCR when it is the chat model, or with `vision_llm="myprovider/model-vl"`. |
|
|
709
|
+
|
|
710
|
+
Models you don't list still work (`llm="myprovider/any-model"`). The list sets the default model and the flags.
|
|
711
|
+
|
|
712
|
+
Reasoning models spend completion tokens on thinking before they answer. A small `llm_max_tokens` can be used up entirely by the thinking, which leaves the answer empty, so leave it unset or generous for these models.
|
|
713
|
+
|
|
714
|
+
More options for servers with their own conventions:
|
|
715
|
+
|
|
716
|
+
| Option | Example | Use |
|
|
717
|
+
| :--- | :--- | :--- |
|
|
718
|
+
| `extra_body` | `{"chat_template_kwargs": {"enable_thinking": False}}` | Extra JSON fields for every chat request (vLLM / NVIDIA NIM sampling or template options). Turning thinking off for NVIDIA Nemotron cut a lookup answer from 357 to 10 completion tokens and from 2.7 s to 0.5 s in testing. |
|
|
719
|
+
| `embedding_input_types` | `["passage", "query"]` | Asymmetric embedding models that require an `input_type` field: documents get the first value, search queries the second. |
|
|
720
|
+
| `embedding_params` | `{"truncate": "END"}` | Extra JSON fields for embedding requests. |
|
|
721
|
+
| `stream_usage` | `true` | The server accepts `stream_options.include_usage`, so streamed answers report real token counts. |
|
|
722
|
+
|
|
723
|
+
**From a JSON file** (no code). Use `load_providers("providers.json")`, set `RAGLIB_PROVIDERS_FILE=providers.json`, or pass `raglib ask ... --providers providers.json`:
|
|
724
|
+
|
|
725
|
+
```json
|
|
726
|
+
{
|
|
727
|
+
"providers": {
|
|
728
|
+
"myprovider": {
|
|
729
|
+
"name": "My AI Provider",
|
|
730
|
+
"api": "openai",
|
|
731
|
+
"base_url": "https://api.myprovider.com/v1",
|
|
732
|
+
"api_key": "{env:MYPROVIDER_API_KEY}",
|
|
733
|
+
"headers": {"X-Team": "search"},
|
|
734
|
+
"models": {
|
|
735
|
+
"model-id": {"name": "Display Name", "reasoning": false, "image": false}
|
|
736
|
+
},
|
|
737
|
+
"embedding_model": "embed-v1"
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
Keep keys out of the file with `{env:NAME}`; raglib warns when a file holds a literal key. A key given for one provider is never sent to another provider's host. Built-in provider ids can't be redefined, and `raglib providers` lists custom providers with their models.
|
|
744
|
+
|
|
655
745
|
### Supported Embedding Providers (`embedding_llm`)
|
|
656
746
|
|
|
657
747
|
| Provider | `embedding_llm` Value | Default Model | Notes |
|
|
@@ -671,10 +761,12 @@ If `embedding_llm` is omitted, raglib uses the chat provider's embeddings (OpenA
|
|
|
671
761
|
### Vector Stores (`vector_db`)
|
|
672
762
|
|
|
673
763
|
- **`"memory"`** *(default)*: in-RAM cosine search (numpy-accelerated when installed), persisted with `rag.save()` / `rag.load()`.
|
|
764
|
+
- **`"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.
|
|
765
|
+
- **`"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
766
|
- **`"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
767
|
- **Your own**: subclass `BaseVectorStore` (`upsert`, `query(filters=...)`, `delete`, `count`).
|
|
676
768
|
|
|
677
|
-
Initialization errors are raised. Pass `vector_db_kwargs={"fallback_to_memory": True}` to opt into a fallback.
|
|
769
|
+
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
770
|
|
|
679
771
|
---
|
|
680
772
|
|
|
@@ -709,6 +801,10 @@ rag.query("What is our authentication service called?", session_id="user-42")
|
|
|
709
801
|
rag.query("Which downstream services depend on it?", session_id="user-42")
|
|
710
802
|
rag.reset_memory("user-42")
|
|
711
803
|
|
|
804
|
+
# Persist conversations across restarts and worker processes
|
|
805
|
+
from raglib import SQLiteConversationStore
|
|
806
|
+
rag = RAG("docs/", chat_llm="openai", memory=True, conversation_store=SQLiteConversationStore("chats.db", ttl_seconds=86400))
|
|
807
|
+
|
|
712
808
|
# Streaming
|
|
713
809
|
for token in rag.stream("Summarize the onboarding guide"):
|
|
714
810
|
print(token, end="", flush=True)
|
|
@@ -719,7 +815,8 @@ for token in rag.stream("Summarize the onboarding guide"):
|
|
|
719
815
|
# Tracing: every stage is timed; plug in LangSmith / OpenTelemetry / logging
|
|
720
816
|
rag = RAG("docs/", chat_llm="openai", on_event=lambda e: print(e.stage, e.latency_ms, e.meta))
|
|
721
817
|
result = rag.query("...")
|
|
722
|
-
print(result.usage) #
|
|
818
|
+
print(result.usage) # answer call + totals over every LLM call of the query (see below)
|
|
819
|
+
print(result.metadata.get("degraded")) # optional steps that failed and fell back, if any
|
|
723
820
|
|
|
724
821
|
rag.chat() # interactive terminal session with memory
|
|
725
822
|
```
|
|
@@ -731,13 +828,13 @@ rag.chat() # interactive terminal session with memory
|
|
|
731
828
|
```python
|
|
732
829
|
from raglib import RAG
|
|
733
830
|
from raglib.eval import evaluate
|
|
734
|
-
from raglib.llm
|
|
831
|
+
from raglib.llm import build_chat_client
|
|
735
832
|
|
|
736
833
|
rag = RAG("docs/", chat_llm="openai", embedding_llm="openai")
|
|
737
834
|
dataset = [
|
|
738
835
|
{"question": "What is the refund window?", "relevant_ids": ["docs/refunds.md"], "reference": "30 days"},
|
|
739
836
|
]
|
|
740
|
-
judge =
|
|
837
|
+
judge = build_chat_client("openai", model_name="gpt-4.1") # use a strong judge model
|
|
741
838
|
report = evaluate(rag, dataset, judge_llm=judge, k=5)
|
|
742
839
|
print(report) # hit_rate@5, mrr@5, recall@5, ndcg@5, faithfulness, answer_relevance, context_precision, correctness, latency_ms
|
|
743
840
|
```
|
|
@@ -767,7 +864,7 @@ corpus = [
|
|
|
767
864
|
Document(id="d2", content="Corrective RAG grades chunks and refines knowledge strips."),
|
|
768
865
|
]
|
|
769
866
|
|
|
770
|
-
llm = MockLLMClient() # use
|
|
867
|
+
llm = MockLLMClient() # use build_chat_client("openai") in production
|
|
771
868
|
pipeline = CorrectiveRAG(
|
|
772
869
|
retriever=Retriever(documents=corpus, top_k=4), # BM25 only; pass embedding=... for hybrid
|
|
773
870
|
grader=RelevanceGrader(llm_client=llm),
|
|
@@ -781,7 +878,9 @@ result = pipeline.run("How does Corrective RAG handle low-scoring chunks?")
|
|
|
781
878
|
print(result.answer, result.reasoning_trace)
|
|
782
879
|
```
|
|
783
880
|
|
|
784
|
-
Subclass `BaseRAG` and override `retrieve(ctx)` (or `process_documents` / `generate` / `answer`) to build your own strategy. Condensation, memory, tracing, citations and
|
|
881
|
+
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.
|
|
882
|
+
|
|
883
|
+
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
884
|
|
|
786
885
|
---
|
|
787
886
|
|
|
@@ -798,8 +897,8 @@ from raglib import Document, GenerationResult, Citation, TraceEvent, QueryResult
|
|
|
798
897
|
- `citations: List[Citation]` — `[n]` markers in the answer mapped to sources (`index`, `document_id`, `source`, `snippet`)
|
|
799
898
|
- `reasoning_trace: List[str]` — human-readable pipeline steps
|
|
800
899
|
- `trace_events: List[TraceEvent]` — `stage`, `latency_ms`, `meta`, `error` per stage
|
|
801
|
-
- `usage: Dict` —
|
|
802
|
-
- `metadata: Dict` — pipeline name, standalone search query, session id, strategy details
|
|
900
|
+
- `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`
|
|
901
|
+
- `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
902
|
- **GraphRAG**: `raglib.graphrag.Entity`, `Relation`, `Community`
|
|
804
903
|
|
|
805
904
|
---
|
|
@@ -828,7 +927,8 @@ raglib graph papers/ --out graph.html
|
|
|
828
927
|
| 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
928
|
| 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
929
|
| 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),
|
|
930
|
+
| 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. |
|
|
931
|
+
| `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
932
|
| User-supplied file paths | `allowed_dirs=[...]` sandboxes file and folder sources (resolves `..` and symlinks). | Always set it when paths come from users. |
|
|
833
933
|
| 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
934
|
| 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. |
|