-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy path__init__.py
More file actions
155 lines (150 loc) · 4.89 KB
/
__init__.py
File metadata and controls
155 lines (150 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
from .factory import (
build_db_from_env,
build_embedding_from_env,
build_explorer_from_url,
build_llm_from_env,
)
from .components.enrichment.context_enricher import ContextEnricher
from .components.enrichment.question_profiler import QuestionProfiler
from .components.execution.sql_executor import SQLExecutor
from .components.gate.question_gate import QuestionGate
from .components.gate.table_suitability import TableSuitabilityEvaluator
from .components.generation.sql_generator import SQLGenerator
from .components.loaders.directory_ import DirectoryLoader
from .components.loaders.markdown_ import MarkdownLoader
from .components.loaders.plaintext_ import PlainTextLoader
from .components.retrieval.chunker import (
CatalogChunker,
DocumentChunkerPort,
RecursiveCharacterChunker,
)
from .components.retrieval.hybrid import HybridRetriever
from .components.retrieval.keyword import KeywordRetriever
from .components.retrieval.vector import VectorRetriever
from .core.catalog import (
CatalogEntry,
GateResult,
IndexedChunk,
QuestionProfile,
RetrievalResult,
TableScore,
TextDocument,
)
from .core.exceptions import ComponentError, IntegrationMissingError, Lang2SQLError
from .core.hooks import MemoryHook, NullHook, TraceHook
from .core.ports import (
CatalogLoaderPort,
DBExplorerPort,
DBPort,
DocumentLoaderPort,
EmbeddingPort,
LLMPort,
VectorStorePort,
)
from .integrations.db.sqlalchemy_ import SQLAlchemyExplorer
from .flows.enriched_nl2sql import EnrichedNL2SQL
from .flows.hybrid import HybridNL2SQL
from .flows.nl2sql import BaselineNL2SQL
from .integrations.embedding.azure_ import AzureOpenAIEmbedding
from .integrations.embedding.bedrock_ import BedrockEmbedding
from .integrations.embedding.gemini_ import GeminiEmbedding
from .integrations.embedding.huggingface_ import HuggingFaceEmbedding
from .integrations.embedding.ollama_ import OllamaEmbedding
from .integrations.llm.azure_ import AzureOpenAILLM
from .integrations.llm.bedrock_ import BedrockLLM
from .integrations.llm.gemini_ import GeminiLLM
from .integrations.llm.huggingface_ import HuggingFaceLLM
from .integrations.llm.ollama_ import OllamaLLM
__all__ = [
# Data types
"CatalogEntry",
"TextDocument",
"IndexedChunk",
"RetrievalResult",
# Domain types (Phase 4)
"GateResult",
"QuestionProfile",
"TableScore",
# Ports (protocols)
"LLMPort",
"DBPort",
"DBExplorerPort",
"EmbeddingPort",
"VectorStorePort",
"DocumentLoaderPort",
"CatalogLoaderPort",
# Components — retrieval
"KeywordRetriever",
"VectorRetriever",
"HybridRetriever",
"DocumentChunkerPort",
"CatalogChunker",
"RecursiveCharacterChunker",
# Components — generation & execution
"SQLGenerator",
"SQLExecutor",
# Components — gate (Phase 4)
"QuestionGate",
"TableSuitabilityEvaluator",
# Components — enrichment (Phase 4)
"QuestionProfiler",
"ContextEnricher",
# Components — loaders
"MarkdownLoader",
"PlainTextLoader",
"DirectoryLoader",
# Flows
"BaselineNL2SQL",
"HybridNL2SQL",
"EnrichedNL2SQL",
# Hooks
"TraceHook",
"MemoryHook",
"NullHook",
# Exceptions
"Lang2SQLError",
"ComponentError",
"IntegrationMissingError",
# Vector store backends
"FAISSVectorStore",
"PGVectorStore",
# LLM integrations (Phase 1)
"AzureOpenAILLM",
"BedrockLLM",
"GeminiLLM",
"HuggingFaceLLM",
"OllamaLLM",
# Embedding integrations (Phase 2)
"AzureOpenAIEmbedding",
"BedrockEmbedding",
"GeminiEmbedding",
"HuggingFaceEmbedding",
"OllamaEmbedding",
# Catalog integrations (Phase 3)
"DataHubCatalogLoader",
# DB Explorer (Phase A1)
"SQLAlchemyExplorer",
# Factory (Phase 6)
"build_llm_from_env",
"build_embedding_from_env",
"build_db_from_env",
"build_explorer_from_url",
]
# ---------------------------------------------------------------------------
# Lazy imports (PEP 562) — optional dependencies that have import side-effects
# (e.g. faiss prints INFO logs on import) or are rarely needed at startup.
# ---------------------------------------------------------------------------
_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
"DataHubCatalogLoader": (".integrations.catalog.datahub_", "DataHubCatalogLoader"),
"FAISSVectorStore": (".integrations.vectorstore.faiss_", "FAISSVectorStore"),
"PGVectorStore": (".integrations.vectorstore.pgvector_", "PGVectorStore"),
}
def __getattr__(name: str):
if name in _LAZY_IMPORTS:
module_path, attr = _LAZY_IMPORTS[name]
import importlib
obj = getattr(importlib.import_module(module_path, package=__name__), attr)
# Cache in module globals so subsequent accesses skip __getattr__
globals()[name] = obj
return obj
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")