adaptive-intelligence 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,23 @@
1
+ """
2
+ Adaptive Intelligence — Self-Improving Retrieval Orchestration Framework
3
+
4
+ Drop documents. Ask questions. The system learns how to retrieve better over time.
5
+
6
+ Usage:
7
+ from adaptive_intelligence import AdaptiveAI
8
+
9
+ engine = AdaptiveAI()
10
+ engine.ingest("./documents")
11
+ response = engine.ask("What are the operational risks?")
12
+ print(response.answer)
13
+ print(response.confidence)
14
+ print(response.citations)
15
+ """
16
+
17
+ __version__ = "0.1.0"
18
+ __author__ = "VK Venkatkumar"
19
+
20
+ from adaptive_intelligence.core.engine import AdaptiveAI
21
+ from adaptive_intelligence.core.response import AdaptiveResponse
22
+
23
+ __all__ = ["AdaptiveAI", "AdaptiveResponse"]
@@ -0,0 +1,3 @@
1
+ from adaptive_intelligence.core.engine import AdaptiveAI
2
+ from adaptive_intelligence.core.response import AdaptiveResponse
3
+ from adaptive_intelligence.core.config import AdaptiveConfig
@@ -0,0 +1,149 @@
1
+ """Configuration for Adaptive Intelligence engine."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Optional, Dict, Any, List
5
+ from enum import Enum
6
+ from pathlib import Path
7
+
8
+
9
+ class LLMBackend(str, Enum):
10
+ OLLAMA = "ollama"
11
+ OPENAI = "openai"
12
+ AZURE_OPENAI = "azure_openai"
13
+ ANTHROPIC = "anthropic"
14
+ HUGGINGFACE = "huggingface"
15
+ GROQ = "groq"
16
+ TOGETHER = "together"
17
+ CUSTOM = "custom"
18
+
19
+
20
+ class SecurityLevel(str, Enum):
21
+ STANDARD = "standard"
22
+ HIGH = "high"
23
+ MAXIMUM = "maximum"
24
+
25
+
26
+ class Domain(str, Enum):
27
+ GENERAL = "general"
28
+ FINANCIAL = "financial"
29
+ LEGAL = "legal"
30
+ TECHNICAL = "technical"
31
+ HEALTHCARE = "healthcare"
32
+ SCIENTIFIC = "scientific"
33
+ OPERATIONAL = "operational"
34
+
35
+
36
+ @dataclass
37
+ class ChunkingConfig:
38
+ chunk_size: int = 500
39
+ chunk_overlap: int = 50
40
+ respect_boundaries: bool = True
41
+ min_chunk_size: int = 100
42
+
43
+
44
+ @dataclass
45
+ class RLConfig:
46
+ warmup_queries: int = 15
47
+ exploration_rate: float = 0.2
48
+ min_exploration_rate: float = 0.05
49
+ exploration_decay: float = 0.995
50
+ learning_rate: float = 0.1
51
+ discount_factor: float = 0.95
52
+ update_frequency: int = 5
53
+ algorithm: str = "thompson_sampling" # "epsilon_greedy", "ucb", "thompson_sampling"
54
+
55
+
56
+ @dataclass
57
+ class GraphConfig:
58
+ enabled: bool = True
59
+ conditional_activation: bool = True
60
+ max_hops: int = 3
61
+ min_entity_count_for_activation: int = 2
62
+ relationship_confidence_threshold: float = 0.5
63
+ activation_success_threshold: float = 0.7
64
+
65
+
66
+ @dataclass
67
+ class EvaluationConfig:
68
+ faithfulness_weight: float = 0.30
69
+ relevance_weight: float = 0.20
70
+ citation_weight: float = 0.20
71
+ precision_weight: float = 0.10
72
+ recall_weight: float = 0.10
73
+ latency_penalty_weight: float = 0.05
74
+ token_cost_weight: float = 0.03
75
+ hallucination_penalty_weight: float = 0.02
76
+ llm_judge_threshold: float = 0.8
77
+ enable_llm_judge: bool = True
78
+ enable_consistency_checks: bool = False
79
+
80
+
81
+ @dataclass
82
+ class AdaptiveConfig:
83
+ # LLM Configuration
84
+ llm_backend: LLMBackend = LLMBackend.OLLAMA
85
+ llm_model: str = "llama3.2"
86
+ base_url: Optional[str] = None
87
+ api_key: Optional[str] = None
88
+ azure_endpoint: Optional[str] = None
89
+ deployment_name: Optional[str] = None
90
+ temperature: float = 0.1
91
+ max_tokens: int = 2048
92
+
93
+ # Domain
94
+ domain: Domain = Domain.GENERAL
95
+
96
+ # Security
97
+ security_level: SecurityLevel = SecurityLevel.STANDARD
98
+ network_enabled: bool = False
99
+ enable_audit_trail: bool = True
100
+
101
+ # Storage
102
+ storage_dir: str = "./.adaptive_intelligence"
103
+ vector_db: str = "chromadb"
104
+
105
+ # Chunking
106
+ chunking: ChunkingConfig = field(default_factory=ChunkingConfig)
107
+
108
+ # RL Engine
109
+ rl: RLConfig = field(default_factory=RLConfig)
110
+
111
+ # Graph
112
+ graph: GraphConfig = field(default_factory=GraphConfig)
113
+
114
+ # Evaluation
115
+ evaluation: EvaluationConfig = field(default_factory=EvaluationConfig)
116
+
117
+ # Retrieval
118
+ default_retrieval_depth: int = 5
119
+ max_retrieval_depth: int = 20
120
+ enable_reranking: bool = True
121
+
122
+ # Logging
123
+ log_level: str = "INFO"
124
+ log_file: Optional[str] = None
125
+
126
+ def to_dict(self) -> Dict[str, Any]:
127
+ """Serialize config to dictionary."""
128
+ import dataclasses
129
+ return dataclasses.asdict(self)
130
+
131
+ @classmethod
132
+ def from_dict(cls, data: Dict[str, Any]) -> "AdaptiveConfig":
133
+ """Create config from dictionary."""
134
+ # Handle nested dataclasses
135
+ if "chunking" in data and isinstance(data["chunking"], dict):
136
+ data["chunking"] = ChunkingConfig(**data["chunking"])
137
+ if "rl" in data and isinstance(data["rl"], dict):
138
+ data["rl"] = RLConfig(**data["rl"])
139
+ if "graph" in data and isinstance(data["graph"], dict):
140
+ data["graph"] = GraphConfig(**data["graph"])
141
+ if "evaluation" in data and isinstance(data["evaluation"], dict):
142
+ data["evaluation"] = EvaluationConfig(**data["evaluation"])
143
+ if "llm_backend" in data and isinstance(data["llm_backend"], str):
144
+ data["llm_backend"] = LLMBackend(data["llm_backend"])
145
+ if "security_level" in data and isinstance(data["security_level"], str):
146
+ data["security_level"] = SecurityLevel(data["security_level"])
147
+ if "domain" in data and isinstance(data["domain"], str):
148
+ data["domain"] = Domain(data["domain"])
149
+ return cls(**data)