adaptive-intelligence 4.0.1__tar.gz → 4.0.2__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 (50) hide show
  1. adaptive_intelligence-4.0.2/PKG-INFO +311 -0
  2. adaptive_intelligence-4.0.2/README.md +241 -0
  3. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/__init__.py +1 -1
  4. adaptive_intelligence-4.0.2/adaptive_intelligence.egg-info/PKG-INFO +311 -0
  5. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/pyproject.toml +2 -2
  6. adaptive_intelligence-4.0.1/PKG-INFO +0 -388
  7. adaptive_intelligence-4.0.1/README.md +0 -318
  8. adaptive_intelligence-4.0.1/adaptive_intelligence.egg-info/PKG-INFO +0 -388
  9. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/LICENSE +0 -0
  10. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/agentic/__init__.py +0 -0
  11. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/context/__init__.py +0 -0
  12. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/core/__init__.py +0 -0
  13. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/core/config.py +0 -0
  14. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/core/engine.py +0 -0
  15. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/core/response.py +0 -0
  16. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/evaluation/__init__.py +0 -0
  17. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/graph/__init__.py +0 -0
  18. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/indexes/__init__.py +0 -0
  19. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/indexes/base.py +0 -0
  20. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/indexes/keyword_index.py +0 -0
  21. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/indexes/page_index.py +0 -0
  22. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/indexes/vector_index.py +0 -0
  23. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/ingestion/__init__.py +0 -0
  24. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/ingestion/chunker.py +0 -0
  25. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/ingestion/engine.py +0 -0
  26. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/ingestion/parser.py +0 -0
  27. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/llm/__init__.py +0 -0
  28. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/mcp/__init__.py +0 -0
  29. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/memory/__init__.py +0 -0
  30. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/memory/persistent.py +0 -0
  31. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/prompts/__init__.py +0 -0
  32. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/query/__init__.py +0 -0
  33. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/rl/__init__.py +0 -0
  34. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/rl/multi_query.py +0 -0
  35. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/rl/ppo.py +0 -0
  36. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/rl/pretrained.py +0 -0
  37. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/rl/reranker.py +0 -0
  38. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/security/__init__.py +0 -0
  39. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence/utils/__init__.py +0 -0
  40. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence.egg-info/SOURCES.txt +0 -0
  41. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence.egg-info/dependency_links.txt +0 -0
  42. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence.egg-info/requires.txt +0 -0
  43. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/adaptive_intelligence.egg-info/top_level.txt +0 -0
  44. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/setup.cfg +0 -0
  45. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/tests/test_core.py +0 -0
  46. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/tests/test_evaluation.py +0 -0
  47. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/tests/test_graph.py +0 -0
  48. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/tests/test_ingestion.py +0 -0
  49. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/tests/test_query.py +0 -0
  50. {adaptive_intelligence-4.0.1 → adaptive_intelligence-4.0.2}/tests/test_rl.py +0 -0
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.4
2
+ Name: adaptive-intelligence
3
+ Version: 4.0.2
4
+ Summary: Self-improving retrieval framework with RL routing, context engineering, MCP integration, agentic workflow, and persistent memory.
5
+ Author-email: Venkatkumar Rajan <venkatkumarr.vk99@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/VK-Ant/adaptive-intelligence
8
+ Project-URL: Documentation, https://github.com/VK-Ant/adaptive-intelligence#readme
9
+ Project-URL: Repository, https://github.com/VK-Ant/adaptive-intelligence
10
+ Project-URL: Issues, https://github.com/VK-Ant/adaptive-intelligence/issues
11
+ Project-URL: PyPI, https://pypi.org/project/adaptive-intelligence/
12
+ Project-URL: Paper, https://www.researchgate.net/publication/405076088
13
+ Project-URL: Portfolio, https://vk-ant.github.io/Venkatkumar/
14
+ Project-URL: Changelog, https://github.com/VK-Ant/adaptive-intelligence/blob/main/CHANGELOG.md
15
+ Keywords: rag,retrieval,reinforcement-learning,knowledge-graph,document-intelligence,adaptive,self-improving,llm,ai,nlp,evaluation,self-learning,context-engineering,mcp,agentic,memory,tool-use,multi-agent
16
+ Classifier: Development Status :: 4 - Beta
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Intended Audience :: Science/Research
19
+ Classifier: License :: OSI Approved :: Apache Software License
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Provides-Extra: vector
31
+ Requires-Dist: chromadb>=0.4.0; extra == "vector"
32
+ Provides-Extra: openai
33
+ Requires-Dist: openai>=1.0.0; extra == "openai"
34
+ Provides-Extra: huggingface
35
+ Requires-Dist: transformers>=4.35.0; extra == "huggingface"
36
+ Requires-Dist: torch>=2.0.0; extra == "huggingface"
37
+ Provides-Extra: pdf
38
+ Requires-Dist: PyMuPDF>=1.23.0; extra == "pdf"
39
+ Provides-Extra: docx
40
+ Requires-Dist: python-docx>=1.0.0; extra == "docx"
41
+ Provides-Extra: xlsx
42
+ Requires-Dist: openpyxl>=3.1.0; extra == "xlsx"
43
+ Provides-Extra: pptx
44
+ Requires-Dist: python-pptx>=0.6.21; extra == "pptx"
45
+ Provides-Extra: sql
46
+ Requires-Dist: sqlalchemy>=2.0.0; extra == "sql"
47
+ Provides-Extra: rerank
48
+ Requires-Dist: sentence-transformers>=2.2.0; extra == "rerank"
49
+ Provides-Extra: ocr
50
+ Requires-Dist: pytesseract>=0.3.10; extra == "ocr"
51
+ Requires-Dist: Pillow>=10.0; extra == "ocr"
52
+ Provides-Extra: all
53
+ Requires-Dist: chromadb>=0.4.0; extra == "all"
54
+ Requires-Dist: openai>=1.0.0; extra == "all"
55
+ Requires-Dist: transformers>=4.35.0; extra == "all"
56
+ Requires-Dist: torch>=2.0.0; extra == "all"
57
+ Requires-Dist: PyMuPDF>=1.23.0; extra == "all"
58
+ Requires-Dist: python-docx>=1.0.0; extra == "all"
59
+ Requires-Dist: openpyxl>=3.1.0; extra == "all"
60
+ Requires-Dist: python-pptx>=0.6.21; extra == "all"
61
+ Requires-Dist: pytesseract>=0.3.10; extra == "all"
62
+ Requires-Dist: Pillow>=10.0; extra == "all"
63
+ Requires-Dist: sentence-transformers>=2.2.0; extra == "all"
64
+ Provides-Extra: dev
65
+ Requires-Dist: pytest>=7.0; extra == "dev"
66
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
67
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
68
+ Requires-Dist: mypy>=1.5; extra == "dev"
69
+ Dynamic: license-file
70
+
71
+ # adaptive-intelligence
72
+
73
+ Self-improving retrieval framework that learns, remembers, and connects tools.
74
+
75
+ ## What it does
76
+
77
+ Instead of using the same retrieval strategy for every query, adaptive-intelligence uses reinforcement learning to select the best strategy per query type. The system evaluates every response, uses the score as a reward signal, and improves with every query answered.
78
+
79
+ <img src="https://raw.githubusercontent.com/VK-Ant/adaptive-intelligence/main/docs/images/image_ai.png" alt="adaptive-intelligence" width="100%">
80
+
81
+ ## Install
82
+
83
+ ```bash
84
+ pip install adaptive-intelligence # Zero deps (Ollama, no-LLM mode)
85
+ pip install adaptive-intelligence[vector] # + ChromaDB vector search
86
+ pip install adaptive-intelligence[openai] # + Any OpenAI-compatible API (10+ providers)
87
+ pip install adaptive-intelligence[huggingface] # + Local HuggingFace models
88
+ pip install adaptive-intelligence[all] # Everything
89
+ ```
90
+
91
+ ## Quick start
92
+
93
+ ```python
94
+ from adaptive_intelligence import AdaptiveAI
95
+
96
+ engine = AdaptiveAI()
97
+ engine.ingest("./documents")
98
+ response = engine.ask("What are the key risks?")
99
+ print(response.answer)
100
+ ```
101
+
102
+ Works without any LLM — returns relevant document excerpts. Add an LLM for synthesized answers.
103
+
104
+ ## LLM providers
105
+
106
+ The library works with any LLM. The `[openai]` extras installs the OpenAI SDK which connects to any OpenAI-compatible API.
107
+
108
+ ### Free (no credit card needed)
109
+
110
+ ```python
111
+ # Ollama — local, no extras needed
112
+ engine = AdaptiveAI()
113
+
114
+ # NVIDIA NIM — free cloud tier
115
+ engine = AdaptiveAI(
116
+ api_key="nvapi-...",
117
+ base_url="https://integrate.api.nvidia.com/v1",
118
+ llm_model="meta/llama-3.1-70b-instruct"
119
+ )
120
+
121
+ # Groq — free cloud tier
122
+ engine = AdaptiveAI(
123
+ api_key="gsk_...",
124
+ base_url="https://api.groq.com/openai/v1",
125
+ llm_model="llama-3.3-70b-versatile"
126
+ )
127
+
128
+ # Google Gemini — free tier
129
+ engine = AdaptiveAI(
130
+ api_key="...",
131
+ base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
132
+ llm_model="gemini-2.0-flash"
133
+ )
134
+
135
+ # Together AI — free tier
136
+ engine = AdaptiveAI(
137
+ api_key="...",
138
+ base_url="https://api.together.xyz/v1",
139
+ llm_model="meta-llama/Llama-3-70b-chat-hf"
140
+ )
141
+
142
+ # Fireworks AI — free tier
143
+ engine = AdaptiveAI(
144
+ api_key="...",
145
+ base_url="https://api.fireworks.ai/inference/v1",
146
+ llm_model="accounts/fireworks/models/llama-v3p1-70b-instruct"
147
+ )
148
+
149
+ # HuggingFace local — runs on your GPU, needs [huggingface] extras
150
+ engine = AdaptiveAI(
151
+ llm_backend="huggingface",
152
+ llm_model="Qwen/Qwen2.5-1.5B-Instruct"
153
+ )
154
+
155
+ # No LLM — retrieval only, zero dependencies
156
+ engine = AdaptiveAI(llm_backend="none")
157
+ ```
158
+
159
+ ### Paid
160
+
161
+ ```python
162
+ # OpenAI
163
+ engine = AdaptiveAI(api_key="sk-...", llm_model="gpt-4o")
164
+
165
+ # Grok (xAI)
166
+ engine = AdaptiveAI(api_key="xai-...", base_url="https://api.x.ai/v1")
167
+
168
+ # Azure OpenAI
169
+ engine = AdaptiveAI(azure_endpoint="https://your.openai.azure.com/", api_key="...")
170
+ ```
171
+
172
+ ### Self-hosted
173
+
174
+ ```python
175
+ # vLLM local server (free, runs on your GPU)
176
+ engine = AdaptiveAI(base_url="http://localhost:8000/v1")
177
+
178
+ # Any OpenAI-compatible server
179
+ engine = AdaptiveAI(base_url="http://your-server:8000/v1")
180
+ ```
181
+
182
+ Any server that speaks the OpenAI-compatible API works with `[openai]` extras.
183
+
184
+ ## Key features
185
+
186
+ ### Context Engineering
187
+ Optimizes the entire context window — not just which chunks to retrieve, but what memory to include, how much history to keep, which tool results to add, and how to structure the prompt.
188
+
189
+ ```python
190
+ engine = AdaptiveAI(context_engineering=True)
191
+ ```
192
+
193
+ ### MCP Integration
194
+ Connect external tools. Register MCP servers, REST APIs, or Python functions. The RL policy learns which tools to call per query type.
195
+
196
+ ```python
197
+ # Register tools
198
+ engine.add_tool("financial", server="http://localhost:8081")
199
+ engine.add_tool("calculator", function=my_calc_function)
200
+ engine.add_tool("search", api_endpoint="https://api.example.com/search")
201
+
202
+ # List registered tools
203
+ engine.list_tools()
204
+
205
+ # Remove a tool
206
+ engine.remove_tool("search")
207
+
208
+ # Serve your retrieval as an MCP server
209
+ engine.serve_mcp(port=8080)
210
+ ```
211
+
212
+ ### Agentic Workflow
213
+ Multi-round retrieval. The system retrieves, evaluates confidence, refines the query, calls tools, and retrieves again until the answer is sufficient.
214
+
215
+ ```python
216
+ response = engine.ask("Analyze supply chain risks and mitigation", mode="agentic")
217
+ ```
218
+
219
+ ### Persistent Memory
220
+ Remembers across sessions. Routing patterns, user preferences, and facts persist to disk.
221
+
222
+ ```python
223
+ engine.remember("focus_area", "supply chain risk")
224
+ engine.recall("focus_area")
225
+ engine.search_memory("supply chain")
226
+ ```
227
+
228
+ ### Incremental Learning
229
+ Add new documents anytime. The RL policy, knowledge graph, and memory continue from their current state — no restart needed.
230
+
231
+ ```python
232
+ engine.ingest("./initial_docs") # Learn from initial set
233
+ engine.ingest("./quarterly_update.pdf") # Add later, system continues
234
+ ```
235
+
236
+ ### RL-Based Retrieval Routing
237
+ Thompson Sampling or PPO learns which retrieval strategy works best per query type.
238
+
239
+ ```python
240
+ engine = AdaptiveAI(rl_algorithm="ppo")
241
+ engine = AdaptiveAI(pretrained_policy=True, domain="financial")
242
+ engine.export_policy("learned.json") # Transfer to another deployment
243
+ engine.import_policy("learned.json")
244
+ ```
245
+
246
+ ### Conditional Graph Activation
247
+ Knowledge graph auto-built during ingestion. A 5-signal gate activates graph traversal only when the query needs relational reasoning. Saves compute on 70% of queries.
248
+
249
+ ### Vectorless Mode
250
+ No ChromaDB, no embeddings, zero dependencies. Uses page-level BM25 with page citations.
251
+
252
+ ```python
253
+ engine = AdaptiveAI(vectorless=True)
254
+ ```
255
+
256
+ ### Structured Output
257
+
258
+ ```python
259
+ response = engine.ask("Extract metrics", output_format="json")
260
+ response = engine.ask("List items", output_format="csv")
261
+ response = engine.ask("Summarize", output_format="yaml")
262
+ ```
263
+
264
+ ### User Feedback
265
+
266
+ ```python
267
+ response = engine.ask("What are the risks?")
268
+ engine.feedback(response.query_id, "good") # +0.2 RL reward
269
+ engine.feedback(response.query_id, "bad") # -0.3 RL reward + prompt evolution
270
+ ```
271
+
272
+ ## Demos
273
+
274
+ ### Colab notebook (no setup needed)
275
+ Run on free T4 GPU with no API key: `notebooks/adaptive_intelligence_v4_demo.ipynb`
276
+
277
+ ### Local demos
278
+
279
+ ```bash
280
+ cd demo_mcp_agenticai
281
+ pip install -r requirements.txt
282
+ python demo_basic.py # Basic usage + incremental learning
283
+ python demo_tools.py # Tool registry + cost optimization
284
+ python demo_agentic.py # Agentic multi-round retrieval
285
+ python demo_mcp_server.py # Serve as MCP server (terminal 1)
286
+ python demo_mcp_client.py # Connect to MCP server (terminal 2)
287
+ ```
288
+
289
+ ## How it works
290
+
291
+ 1. **Understand** — Trigger interpreter classifies query type, complexity, domain, entities (no LLM call)
292
+ 2. **Decide** — RL policy selects retrieval route, depth, graph activation, tools to call
293
+ 3. **Retrieve** — Executes via vector, BM25, or page index with RRF fusion. Graph activates conditionally.
294
+ 4. **Generate** — Cross-encoder reranks chunks. Context engineer assembles full context window. LLM generates.
295
+ 5. **Learn** — 6 metrics evaluate response. Composite score = RL reward. Policy updates. Next query is better.
296
+
297
+ ## Links
298
+
299
+ - **PyPI:** https://pypi.org/project/adaptive-intelligence/
300
+ - **GitHub:** https://github.com/VK-Ant/adaptive-intelligence
301
+ - **Paper:** https://www.researchgate.net/publication/405076088
302
+ - **Portfolio:** https://vk-ant.github.io/Venkatkumar
303
+ - **Also:** [llmevalkit](https://pypi.org/project/llmevalkit/) — 61 metrics for LLM evaluation
304
+
305
+ ## Author
306
+
307
+ Venkatkumar Rajan | [@VK_Venkatkumar](https://linkedin.com/in/venkatkumarvk)
308
+
309
+ ## License
310
+
311
+ Apache License 2.0
@@ -0,0 +1,241 @@
1
+ # adaptive-intelligence
2
+
3
+ Self-improving retrieval framework that learns, remembers, and connects tools.
4
+
5
+ ## What it does
6
+
7
+ Instead of using the same retrieval strategy for every query, adaptive-intelligence uses reinforcement learning to select the best strategy per query type. The system evaluates every response, uses the score as a reward signal, and improves with every query answered.
8
+
9
+ <img src="https://raw.githubusercontent.com/VK-Ant/adaptive-intelligence/main/docs/images/image_ai.png" alt="adaptive-intelligence" width="100%">
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pip install adaptive-intelligence # Zero deps (Ollama, no-LLM mode)
15
+ pip install adaptive-intelligence[vector] # + ChromaDB vector search
16
+ pip install adaptive-intelligence[openai] # + Any OpenAI-compatible API (10+ providers)
17
+ pip install adaptive-intelligence[huggingface] # + Local HuggingFace models
18
+ pip install adaptive-intelligence[all] # Everything
19
+ ```
20
+
21
+ ## Quick start
22
+
23
+ ```python
24
+ from adaptive_intelligence import AdaptiveAI
25
+
26
+ engine = AdaptiveAI()
27
+ engine.ingest("./documents")
28
+ response = engine.ask("What are the key risks?")
29
+ print(response.answer)
30
+ ```
31
+
32
+ Works without any LLM — returns relevant document excerpts. Add an LLM for synthesized answers.
33
+
34
+ ## LLM providers
35
+
36
+ The library works with any LLM. The `[openai]` extras installs the OpenAI SDK which connects to any OpenAI-compatible API.
37
+
38
+ ### Free (no credit card needed)
39
+
40
+ ```python
41
+ # Ollama — local, no extras needed
42
+ engine = AdaptiveAI()
43
+
44
+ # NVIDIA NIM — free cloud tier
45
+ engine = AdaptiveAI(
46
+ api_key="nvapi-...",
47
+ base_url="https://integrate.api.nvidia.com/v1",
48
+ llm_model="meta/llama-3.1-70b-instruct"
49
+ )
50
+
51
+ # Groq — free cloud tier
52
+ engine = AdaptiveAI(
53
+ api_key="gsk_...",
54
+ base_url="https://api.groq.com/openai/v1",
55
+ llm_model="llama-3.3-70b-versatile"
56
+ )
57
+
58
+ # Google Gemini — free tier
59
+ engine = AdaptiveAI(
60
+ api_key="...",
61
+ base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
62
+ llm_model="gemini-2.0-flash"
63
+ )
64
+
65
+ # Together AI — free tier
66
+ engine = AdaptiveAI(
67
+ api_key="...",
68
+ base_url="https://api.together.xyz/v1",
69
+ llm_model="meta-llama/Llama-3-70b-chat-hf"
70
+ )
71
+
72
+ # Fireworks AI — free tier
73
+ engine = AdaptiveAI(
74
+ api_key="...",
75
+ base_url="https://api.fireworks.ai/inference/v1",
76
+ llm_model="accounts/fireworks/models/llama-v3p1-70b-instruct"
77
+ )
78
+
79
+ # HuggingFace local — runs on your GPU, needs [huggingface] extras
80
+ engine = AdaptiveAI(
81
+ llm_backend="huggingface",
82
+ llm_model="Qwen/Qwen2.5-1.5B-Instruct"
83
+ )
84
+
85
+ # No LLM — retrieval only, zero dependencies
86
+ engine = AdaptiveAI(llm_backend="none")
87
+ ```
88
+
89
+ ### Paid
90
+
91
+ ```python
92
+ # OpenAI
93
+ engine = AdaptiveAI(api_key="sk-...", llm_model="gpt-4o")
94
+
95
+ # Grok (xAI)
96
+ engine = AdaptiveAI(api_key="xai-...", base_url="https://api.x.ai/v1")
97
+
98
+ # Azure OpenAI
99
+ engine = AdaptiveAI(azure_endpoint="https://your.openai.azure.com/", api_key="...")
100
+ ```
101
+
102
+ ### Self-hosted
103
+
104
+ ```python
105
+ # vLLM local server (free, runs on your GPU)
106
+ engine = AdaptiveAI(base_url="http://localhost:8000/v1")
107
+
108
+ # Any OpenAI-compatible server
109
+ engine = AdaptiveAI(base_url="http://your-server:8000/v1")
110
+ ```
111
+
112
+ Any server that speaks the OpenAI-compatible API works with `[openai]` extras.
113
+
114
+ ## Key features
115
+
116
+ ### Context Engineering
117
+ Optimizes the entire context window — not just which chunks to retrieve, but what memory to include, how much history to keep, which tool results to add, and how to structure the prompt.
118
+
119
+ ```python
120
+ engine = AdaptiveAI(context_engineering=True)
121
+ ```
122
+
123
+ ### MCP Integration
124
+ Connect external tools. Register MCP servers, REST APIs, or Python functions. The RL policy learns which tools to call per query type.
125
+
126
+ ```python
127
+ # Register tools
128
+ engine.add_tool("financial", server="http://localhost:8081")
129
+ engine.add_tool("calculator", function=my_calc_function)
130
+ engine.add_tool("search", api_endpoint="https://api.example.com/search")
131
+
132
+ # List registered tools
133
+ engine.list_tools()
134
+
135
+ # Remove a tool
136
+ engine.remove_tool("search")
137
+
138
+ # Serve your retrieval as an MCP server
139
+ engine.serve_mcp(port=8080)
140
+ ```
141
+
142
+ ### Agentic Workflow
143
+ Multi-round retrieval. The system retrieves, evaluates confidence, refines the query, calls tools, and retrieves again until the answer is sufficient.
144
+
145
+ ```python
146
+ response = engine.ask("Analyze supply chain risks and mitigation", mode="agentic")
147
+ ```
148
+
149
+ ### Persistent Memory
150
+ Remembers across sessions. Routing patterns, user preferences, and facts persist to disk.
151
+
152
+ ```python
153
+ engine.remember("focus_area", "supply chain risk")
154
+ engine.recall("focus_area")
155
+ engine.search_memory("supply chain")
156
+ ```
157
+
158
+ ### Incremental Learning
159
+ Add new documents anytime. The RL policy, knowledge graph, and memory continue from their current state — no restart needed.
160
+
161
+ ```python
162
+ engine.ingest("./initial_docs") # Learn from initial set
163
+ engine.ingest("./quarterly_update.pdf") # Add later, system continues
164
+ ```
165
+
166
+ ### RL-Based Retrieval Routing
167
+ Thompson Sampling or PPO learns which retrieval strategy works best per query type.
168
+
169
+ ```python
170
+ engine = AdaptiveAI(rl_algorithm="ppo")
171
+ engine = AdaptiveAI(pretrained_policy=True, domain="financial")
172
+ engine.export_policy("learned.json") # Transfer to another deployment
173
+ engine.import_policy("learned.json")
174
+ ```
175
+
176
+ ### Conditional Graph Activation
177
+ Knowledge graph auto-built during ingestion. A 5-signal gate activates graph traversal only when the query needs relational reasoning. Saves compute on 70% of queries.
178
+
179
+ ### Vectorless Mode
180
+ No ChromaDB, no embeddings, zero dependencies. Uses page-level BM25 with page citations.
181
+
182
+ ```python
183
+ engine = AdaptiveAI(vectorless=True)
184
+ ```
185
+
186
+ ### Structured Output
187
+
188
+ ```python
189
+ response = engine.ask("Extract metrics", output_format="json")
190
+ response = engine.ask("List items", output_format="csv")
191
+ response = engine.ask("Summarize", output_format="yaml")
192
+ ```
193
+
194
+ ### User Feedback
195
+
196
+ ```python
197
+ response = engine.ask("What are the risks?")
198
+ engine.feedback(response.query_id, "good") # +0.2 RL reward
199
+ engine.feedback(response.query_id, "bad") # -0.3 RL reward + prompt evolution
200
+ ```
201
+
202
+ ## Demos
203
+
204
+ ### Colab notebook (no setup needed)
205
+ Run on free T4 GPU with no API key: `notebooks/adaptive_intelligence_v4_demo.ipynb`
206
+
207
+ ### Local demos
208
+
209
+ ```bash
210
+ cd demo_mcp_agenticai
211
+ pip install -r requirements.txt
212
+ python demo_basic.py # Basic usage + incremental learning
213
+ python demo_tools.py # Tool registry + cost optimization
214
+ python demo_agentic.py # Agentic multi-round retrieval
215
+ python demo_mcp_server.py # Serve as MCP server (terminal 1)
216
+ python demo_mcp_client.py # Connect to MCP server (terminal 2)
217
+ ```
218
+
219
+ ## How it works
220
+
221
+ 1. **Understand** — Trigger interpreter classifies query type, complexity, domain, entities (no LLM call)
222
+ 2. **Decide** — RL policy selects retrieval route, depth, graph activation, tools to call
223
+ 3. **Retrieve** — Executes via vector, BM25, or page index with RRF fusion. Graph activates conditionally.
224
+ 4. **Generate** — Cross-encoder reranks chunks. Context engineer assembles full context window. LLM generates.
225
+ 5. **Learn** — 6 metrics evaluate response. Composite score = RL reward. Policy updates. Next query is better.
226
+
227
+ ## Links
228
+
229
+ - **PyPI:** https://pypi.org/project/adaptive-intelligence/
230
+ - **GitHub:** https://github.com/VK-Ant/adaptive-intelligence
231
+ - **Paper:** https://www.researchgate.net/publication/405076088
232
+ - **Portfolio:** https://vk-ant.github.io/Venkatkumar
233
+ - **Also:** [llmevalkit](https://pypi.org/project/llmevalkit/) — 61 metrics for LLM evaluation
234
+
235
+ ## Author
236
+
237
+ Venkatkumar Rajan | [@VK_Venkatkumar](https://linkedin.com/in/venkatkumarvk)
238
+
239
+ ## License
240
+
241
+ Apache License 2.0
@@ -24,7 +24,7 @@ Usage:
24
24
  engine.serve_mcp(port=8080)
25
25
  """
26
26
 
27
- __version__ = "4.0.0"
27
+ __version__ = "4.0.2"
28
28
  __author__ = "Venkatkumar Rajan"
29
29
 
30
30
  from adaptive_intelligence.core.engine import AdaptiveAI