mantisdk 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.
Potentially problematic release.
This version of mantisdk might be problematic. Click here for more details.
- mantisdk/__init__.py +22 -0
- mantisdk/adapter/__init__.py +15 -0
- mantisdk/adapter/base.py +94 -0
- mantisdk/adapter/messages.py +270 -0
- mantisdk/adapter/triplet.py +1028 -0
- mantisdk/algorithm/__init__.py +39 -0
- mantisdk/algorithm/apo/__init__.py +5 -0
- mantisdk/algorithm/apo/apo.py +889 -0
- mantisdk/algorithm/apo/prompts/apply_edit_variant01.poml +22 -0
- mantisdk/algorithm/apo/prompts/apply_edit_variant02.poml +18 -0
- mantisdk/algorithm/apo/prompts/text_gradient_variant01.poml +18 -0
- mantisdk/algorithm/apo/prompts/text_gradient_variant02.poml +16 -0
- mantisdk/algorithm/apo/prompts/text_gradient_variant03.poml +107 -0
- mantisdk/algorithm/base.py +162 -0
- mantisdk/algorithm/decorator.py +264 -0
- mantisdk/algorithm/fast.py +250 -0
- mantisdk/algorithm/gepa/__init__.py +59 -0
- mantisdk/algorithm/gepa/adapter.py +459 -0
- mantisdk/algorithm/gepa/gepa.py +364 -0
- mantisdk/algorithm/gepa/lib/__init__.py +18 -0
- mantisdk/algorithm/gepa/lib/adapters/README.md +12 -0
- mantisdk/algorithm/gepa/lib/adapters/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/README.md +341 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/__init__.py +1 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/anymaths_adapter.py +174 -0
- mantisdk/algorithm/gepa/lib/adapters/anymaths_adapter/requirements.txt +1 -0
- mantisdk/algorithm/gepa/lib/adapters/default_adapter/README.md +0 -0
- mantisdk/algorithm/gepa/lib/adapters/default_adapter/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/default_adapter/default_adapter.py +209 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_adapter/README.md +7 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_adapter/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_adapter/dspy_adapter.py +307 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/README.md +99 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/dspy_program_proposal_signature.py +137 -0
- mantisdk/algorithm/gepa/lib/adapters/dspy_full_program_adapter/full_program_adapter.py +266 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/GEPA_RAG.md +621 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/__init__.py +56 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/evaluation_metrics.py +226 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/generic_rag_adapter.py +496 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/rag_pipeline.py +238 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_store_interface.py +212 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/__init__.py +2 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/chroma_store.py +196 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/lancedb_store.py +422 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/milvus_store.py +409 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/qdrant_store.py +368 -0
- mantisdk/algorithm/gepa/lib/adapters/generic_rag_adapter/vector_stores/weaviate_store.py +418 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/README.md +552 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/__init__.py +37 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/mcp_adapter.py +705 -0
- mantisdk/algorithm/gepa/lib/adapters/mcp_adapter/mcp_client.py +364 -0
- mantisdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/README.md +9 -0
- mantisdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/adapters/terminal_bench_adapter/terminal_bench_adapter.py +217 -0
- mantisdk/algorithm/gepa/lib/api.py +375 -0
- mantisdk/algorithm/gepa/lib/core/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/core/adapter.py +180 -0
- mantisdk/algorithm/gepa/lib/core/data_loader.py +74 -0
- mantisdk/algorithm/gepa/lib/core/engine.py +356 -0
- mantisdk/algorithm/gepa/lib/core/result.py +233 -0
- mantisdk/algorithm/gepa/lib/core/state.py +636 -0
- mantisdk/algorithm/gepa/lib/examples/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/examples/aime.py +24 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/eval_default.py +111 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/prompt-templates/instruction_prompt.txt +9 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/prompt-templates/optimal_prompt.txt +24 -0
- mantisdk/algorithm/gepa/lib/examples/anymaths-bench/train_anymaths.py +177 -0
- mantisdk/algorithm/gepa/lib/examples/dspy_full_program_evolution/arc_agi.ipynb +25705 -0
- mantisdk/algorithm/gepa/lib/examples/dspy_full_program_evolution/example.ipynb +348 -0
- mantisdk/algorithm/gepa/lib/examples/mcp_adapter/__init__.py +4 -0
- mantisdk/algorithm/gepa/lib/examples/mcp_adapter/mcp_optimization_example.py +455 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/RAG_GUIDE.md +613 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/__init__.py +9 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/rag_optimization.py +824 -0
- mantisdk/algorithm/gepa/lib/examples/rag_adapter/requirements-rag.txt +29 -0
- mantisdk/algorithm/gepa/lib/examples/terminal-bench/prompt-templates/instruction_prompt.txt +16 -0
- mantisdk/algorithm/gepa/lib/examples/terminal-bench/prompt-templates/terminus.txt +9 -0
- mantisdk/algorithm/gepa/lib/examples/terminal-bench/train_terminus.py +161 -0
- mantisdk/algorithm/gepa/lib/gepa_utils.py +117 -0
- mantisdk/algorithm/gepa/lib/logging/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/logging/experiment_tracker.py +187 -0
- mantisdk/algorithm/gepa/lib/logging/logger.py +75 -0
- mantisdk/algorithm/gepa/lib/logging/utils.py +103 -0
- mantisdk/algorithm/gepa/lib/proposer/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/proposer/base.py +31 -0
- mantisdk/algorithm/gepa/lib/proposer/merge.py +357 -0
- mantisdk/algorithm/gepa/lib/proposer/reflective_mutation/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/proposer/reflective_mutation/base.py +49 -0
- mantisdk/algorithm/gepa/lib/proposer/reflective_mutation/reflective_mutation.py +176 -0
- mantisdk/algorithm/gepa/lib/py.typed +0 -0
- mantisdk/algorithm/gepa/lib/strategies/__init__.py +0 -0
- mantisdk/algorithm/gepa/lib/strategies/batch_sampler.py +77 -0
- mantisdk/algorithm/gepa/lib/strategies/candidate_selector.py +50 -0
- mantisdk/algorithm/gepa/lib/strategies/component_selector.py +36 -0
- mantisdk/algorithm/gepa/lib/strategies/eval_policy.py +64 -0
- mantisdk/algorithm/gepa/lib/strategies/instruction_proposal.py +127 -0
- mantisdk/algorithm/gepa/lib/utils/__init__.py +10 -0
- mantisdk/algorithm/gepa/lib/utils/stop_condition.py +196 -0
- mantisdk/algorithm/gepa/tracing.py +105 -0
- mantisdk/algorithm/utils.py +177 -0
- mantisdk/algorithm/verl/__init__.py +5 -0
- mantisdk/algorithm/verl/interface.py +202 -0
- mantisdk/cli/__init__.py +56 -0
- mantisdk/cli/prometheus.py +115 -0
- mantisdk/cli/store.py +131 -0
- mantisdk/cli/vllm.py +29 -0
- mantisdk/client.py +408 -0
- mantisdk/config.py +348 -0
- mantisdk/emitter/__init__.py +43 -0
- mantisdk/emitter/annotation.py +370 -0
- mantisdk/emitter/exception.py +54 -0
- mantisdk/emitter/message.py +61 -0
- mantisdk/emitter/object.py +117 -0
- mantisdk/emitter/reward.py +320 -0
- mantisdk/env_var.py +156 -0
- mantisdk/execution/__init__.py +15 -0
- mantisdk/execution/base.py +64 -0
- mantisdk/execution/client_server.py +443 -0
- mantisdk/execution/events.py +69 -0
- mantisdk/execution/inter_process.py +16 -0
- mantisdk/execution/shared_memory.py +282 -0
- mantisdk/instrumentation/__init__.py +119 -0
- mantisdk/instrumentation/agentops.py +314 -0
- mantisdk/instrumentation/agentops_langchain.py +45 -0
- mantisdk/instrumentation/litellm.py +83 -0
- mantisdk/instrumentation/vllm.py +81 -0
- mantisdk/instrumentation/weave.py +500 -0
- mantisdk/litagent/__init__.py +11 -0
- mantisdk/litagent/decorator.py +536 -0
- mantisdk/litagent/litagent.py +252 -0
- mantisdk/llm_proxy.py +1890 -0
- mantisdk/logging.py +370 -0
- mantisdk/reward.py +7 -0
- mantisdk/runner/__init__.py +11 -0
- mantisdk/runner/agent.py +845 -0
- mantisdk/runner/base.py +182 -0
- mantisdk/runner/legacy.py +309 -0
- mantisdk/semconv.py +170 -0
- mantisdk/server.py +401 -0
- mantisdk/store/__init__.py +23 -0
- mantisdk/store/base.py +897 -0
- mantisdk/store/client_server.py +2092 -0
- mantisdk/store/collection/__init__.py +30 -0
- mantisdk/store/collection/base.py +587 -0
- mantisdk/store/collection/memory.py +970 -0
- mantisdk/store/collection/mongo.py +1412 -0
- mantisdk/store/collection_based.py +1823 -0
- mantisdk/store/insight.py +648 -0
- mantisdk/store/listener.py +58 -0
- mantisdk/store/memory.py +396 -0
- mantisdk/store/mongo.py +165 -0
- mantisdk/store/sqlite.py +3 -0
- mantisdk/store/threading.py +357 -0
- mantisdk/store/utils.py +142 -0
- mantisdk/tracer/__init__.py +16 -0
- mantisdk/tracer/agentops.py +242 -0
- mantisdk/tracer/base.py +287 -0
- mantisdk/tracer/dummy.py +106 -0
- mantisdk/tracer/otel.py +555 -0
- mantisdk/tracer/weave.py +677 -0
- mantisdk/trainer/__init__.py +6 -0
- mantisdk/trainer/init_utils.py +263 -0
- mantisdk/trainer/legacy.py +367 -0
- mantisdk/trainer/registry.py +12 -0
- mantisdk/trainer/trainer.py +618 -0
- mantisdk/types/__init__.py +6 -0
- mantisdk/types/core.py +553 -0
- mantisdk/types/resources.py +204 -0
- mantisdk/types/tracer.py +515 -0
- mantisdk/types/tracing.py +218 -0
- mantisdk/utils/__init__.py +1 -0
- mantisdk/utils/id.py +18 -0
- mantisdk/utils/metrics.py +1025 -0
- mantisdk/utils/otel.py +578 -0
- mantisdk/utils/otlp.py +536 -0
- mantisdk/utils/server_launcher.py +1045 -0
- mantisdk/utils/system_snapshot.py +81 -0
- mantisdk/verl/__init__.py +8 -0
- mantisdk/verl/__main__.py +6 -0
- mantisdk/verl/async_server.py +46 -0
- mantisdk/verl/config.yaml +27 -0
- mantisdk/verl/daemon.py +1154 -0
- mantisdk/verl/dataset.py +44 -0
- mantisdk/verl/entrypoint.py +248 -0
- mantisdk/verl/trainer.py +549 -0
- mantisdk-0.1.0.dist-info/METADATA +119 -0
- mantisdk-0.1.0.dist-info/RECORD +190 -0
- mantisdk-0.1.0.dist-info/WHEEL +4 -0
- mantisdk-0.1.0.dist-info/entry_points.txt +2 -0
- mantisdk-0.1.0.dist-info/licenses/LICENSE +19 -0
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
# Generic RAG Adapter for GEPA (DOCS ONLY)
|
|
2
|
+
|
|
3
|
+
A vector store-agnostic RAG (Retrieval-Augmented Generation) adapter that enables GEPA to optimize RAG systems across any vector store implementation.
|
|
4
|
+
|
|
5
|
+
## 🎯 Overview
|
|
6
|
+
|
|
7
|
+
The Generic RAG Adapter brings GEPA's evolutionary optimization to the world of RAG systems. With its pluggable vector store architecture, you can optimize RAG prompts once and deploy across any vector store—from local ChromaDB instances to production Weaviate clusters.
|
|
8
|
+
|
|
9
|
+
**Key Benefits:**
|
|
10
|
+
- **Vector Store Agnostic**: Write once, run anywhere (ChromaDB, Weaviate, Qdrant, Milvus, LanceDB)
|
|
11
|
+
- **Multi-Component Optimization**: Simultaneously optimize query reformulation, context synthesis, answer generation, and reranking
|
|
12
|
+
- **Comprehensive Evaluation**: Both retrieval quality (precision, recall, MRR) and generation quality (F1, BLEU, faithfulness) metrics
|
|
13
|
+
- **Production Ready**: Battle-tested with proper error handling, logging, and performance monitoring
|
|
14
|
+
- **5 Vector Stores Supported**: Complete examples for ChromaDB, Weaviate, Qdrant, Milvus, and LanceDB
|
|
15
|
+
|
|
16
|
+
## 🚀 Quick Start
|
|
17
|
+
|
|
18
|
+
### Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install core GEPA package
|
|
22
|
+
pip install gepa
|
|
23
|
+
|
|
24
|
+
# Install RAG adapter dependencies
|
|
25
|
+
# Navigate to the examples/rag_adapter directory
|
|
26
|
+
cd src/gepa/examples/rag_adapter
|
|
27
|
+
|
|
28
|
+
# Option A: Install all vector store dependencies (recommended for exploration)
|
|
29
|
+
pip install -r requirements-rag.txt
|
|
30
|
+
|
|
31
|
+
# Option B: Install specific vector store dependencies
|
|
32
|
+
pip install litellm chromadb # For ChromaDB
|
|
33
|
+
pip install litellm weaviate-client # For Weaviate
|
|
34
|
+
pip install litellm lancedb pyarrow # For LanceDB
|
|
35
|
+
pip install litellm pymilvus # For Milvus
|
|
36
|
+
pip install litellm qdrant-client # For Qdrant
|
|
37
|
+
|
|
38
|
+
# Setup local Ollama models for examples
|
|
39
|
+
ollama pull qwen3:8b # Default for ChromaDB/Weaviate/Qdrant
|
|
40
|
+
ollama pull llama3.1:8b # Default for LanceDB/Milvus
|
|
41
|
+
ollama pull nomic-embed-text:latest # Embedding model
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Note:** For specific version requirements, see the `requirements-rag.txt` file in the `examples/rag_adapter/` directory.
|
|
45
|
+
|
|
46
|
+
### 5-Minute Example
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import gepa
|
|
50
|
+
from gepa.adapters.generic_rag_adapter import GenericRAGAdapter, ChromaVectorStore
|
|
51
|
+
|
|
52
|
+
# 1. Setup your vector store
|
|
53
|
+
vector_store = ChromaVectorStore.create_local("./knowledge_base", "documents")
|
|
54
|
+
|
|
55
|
+
# 2. Create the RAG adapter
|
|
56
|
+
adapter = GenericRAGAdapter(
|
|
57
|
+
vector_store=vector_store,
|
|
58
|
+
llm_model="ollama/llama3.2:1b", # Memory-friendly local model
|
|
59
|
+
# llm_model="gpt-4", # For cloud-based models (requires API key)
|
|
60
|
+
rag_config={
|
|
61
|
+
"retrieval_strategy": "similarity",
|
|
62
|
+
"top_k": 3 # Reduced for faster local testing
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# 3. Define your training data
|
|
67
|
+
train_data = [
|
|
68
|
+
{
|
|
69
|
+
"query": "What is machine learning?",
|
|
70
|
+
"ground_truth_answer": "Machine learning is...",
|
|
71
|
+
"relevant_doc_ids": ["doc_001"],
|
|
72
|
+
"metadata": {"category": "AI"}
|
|
73
|
+
}
|
|
74
|
+
# ... more examples
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
# 4. Define initial prompts to optimize
|
|
78
|
+
initial_prompts = {
|
|
79
|
+
"answer_generation": "Answer the question based on the provided context.",
|
|
80
|
+
"context_synthesis": "Synthesize the following documents into a coherent context."
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# 5. Run GEPA optimization (local-friendly settings)
|
|
84
|
+
result = gepa.optimize(
|
|
85
|
+
seed_candidate=initial_prompts,
|
|
86
|
+
trainset=train_data,
|
|
87
|
+
valset=validation_data,
|
|
88
|
+
adapter=adapter,
|
|
89
|
+
max_metric_calls=10, # Small number for local testing
|
|
90
|
+
reflection_llm_model="ollama/llama3.1:8b" # Memory-friendly reflection model
|
|
91
|
+
# reflection_llm_model="gpt-4" # For cloud-based optimization
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
print("Optimized RAG prompts:", result.best_candidate)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Vector Store Support
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# ChromaDB (local development, no Docker required)
|
|
101
|
+
vector_store = ChromaVectorStore.create_local("./kb", "docs")
|
|
102
|
+
|
|
103
|
+
# Weaviate (production with hybrid search, Docker required)
|
|
104
|
+
vector_store = WeaviateVectorStore.create_local(
|
|
105
|
+
host="localhost", port=8080, collection_name="KnowledgeBase"
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Qdrant (high performance, Docker optional)
|
|
109
|
+
vector_store = QdrantVectorStore.create_local("./qdrant_db", "KnowledgeBase")
|
|
110
|
+
|
|
111
|
+
# Milvus (cloud-native, uses Milvus Lite by default)
|
|
112
|
+
vector_store = MilvusVectorStore.create_local("KnowledgeBase")
|
|
113
|
+
|
|
114
|
+
# LanceDB (serverless, no Docker required)
|
|
115
|
+
vector_store = LanceDBVectorStore.create_local("./lancedb", "KnowledgeBase")
|
|
116
|
+
|
|
117
|
+
# Same optimization pipeline works with all!
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Optimizable Components:**
|
|
121
|
+
- **Query Reformulation**: Improve user query understanding and reformulation
|
|
122
|
+
- **Context Synthesis**: Optimize document combination and summarization
|
|
123
|
+
- **Answer Generation**: Enhance final answer quality and accuracy
|
|
124
|
+
- **Document Reranking**: Improve retrieved document relevance ordering
|
|
125
|
+
|
|
126
|
+
## 🏗️ Architecture
|
|
127
|
+
|
|
128
|
+
### Vector Store Interface
|
|
129
|
+
|
|
130
|
+
The adapter uses a clean abstraction that any vector store can implement:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
class VectorStoreInterface(ABC):
|
|
134
|
+
@abstractmethod
|
|
135
|
+
def similarity_search(self, query: str, k: int = 5) -> List[Dict[str, Any]]:
|
|
136
|
+
"""Semantic similarity search"""
|
|
137
|
+
|
|
138
|
+
@abstractmethod
|
|
139
|
+
def vector_search(self, query_vector: List[float], k: int = 5) -> List[Dict[str, Any]]:
|
|
140
|
+
"""Direct vector search"""
|
|
141
|
+
|
|
142
|
+
def hybrid_search(self, query: str, k: int = 5, alpha: float = 0.5) -> List[Dict[str, Any]]:
|
|
143
|
+
"""Hybrid semantic + keyword search (optional)"""
|
|
144
|
+
|
|
145
|
+
@abstractmethod
|
|
146
|
+
def get_collection_info(self) -> Dict[str, Any]:
|
|
147
|
+
"""Collection metadata and statistics"""
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### RAG Pipeline Flow
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
User Query → Query Reformulation → Document Retrieval → Document Reranking → Context Synthesis → Answer Generation → Final Answer
|
|
154
|
+
↑ ↑ ↑ ↑ ↑ ↑
|
|
155
|
+
Original Optimizable Vector Store Optimizable Optimizable Optimizable
|
|
156
|
+
Input Prompt Operations Prompt Prompt Prompt
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 🔧 Supported Vector Stores
|
|
160
|
+
|
|
161
|
+
### ChromaDB
|
|
162
|
+
Perfect for local development, prototyping, and smaller deployments. **No Docker required.**
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from gepa.adapters.generic_rag_adapter import ChromaVectorStore
|
|
166
|
+
|
|
167
|
+
# Local persistence
|
|
168
|
+
vector_store = ChromaVectorStore.create_local(
|
|
169
|
+
persist_directory="./chroma_db",
|
|
170
|
+
collection_name="documents"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# In-memory (testing)
|
|
174
|
+
vector_store = ChromaVectorStore.create_memory(
|
|
175
|
+
collection_name="test_docs"
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Weaviate
|
|
180
|
+
Production-grade with advanced features like hybrid search and multi-tenancy. **Docker required.**
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from gepa.adapters.generic_rag_adapter import WeaviateVectorStore
|
|
184
|
+
|
|
185
|
+
# Local Weaviate instance
|
|
186
|
+
vector_store = WeaviateVectorStore.create_local(
|
|
187
|
+
host="localhost",
|
|
188
|
+
port=8080,
|
|
189
|
+
collection_name="Documents"
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
# Weaviate Cloud Services (WCS)
|
|
193
|
+
vector_store = WeaviateVectorStore.create_cloud(
|
|
194
|
+
cluster_url="https://your-cluster.weaviate.network",
|
|
195
|
+
auth_credentials=weaviate.AuthApiKey("your-api-key"),
|
|
196
|
+
collection_name="Documents"
|
|
197
|
+
)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Qdrant
|
|
201
|
+
High-performance vector database with advanced filtering and payload search. **Docker optional.**
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from gepa.adapters.generic_rag_adapter import QdrantVectorStore
|
|
205
|
+
|
|
206
|
+
# In-memory (default, no setup required)
|
|
207
|
+
vector_store = QdrantVectorStore.create_memory("documents")
|
|
208
|
+
|
|
209
|
+
# Local persistent storage
|
|
210
|
+
vector_store = QdrantVectorStore.create_local("./qdrant_db", "documents")
|
|
211
|
+
|
|
212
|
+
# Remote Qdrant server
|
|
213
|
+
vector_store = QdrantVectorStore.create_remote(
|
|
214
|
+
host="localhost", port=6333, collection_name="documents"
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Milvus
|
|
219
|
+
Cloud-native vector database designed for large-scale AI applications. **Uses Milvus Lite by default (no Docker required).**
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from gepa.adapters.generic_rag_adapter import MilvusVectorStore
|
|
223
|
+
|
|
224
|
+
# Milvus Lite (local SQLite-based, no Docker required)
|
|
225
|
+
vector_store = MilvusVectorStore.create_local("documents")
|
|
226
|
+
|
|
227
|
+
# Full Milvus server (Docker required)
|
|
228
|
+
vector_store = MilvusVectorStore.create_remote(
|
|
229
|
+
uri="http://localhost:19530", collection_name="documents"
|
|
230
|
+
)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### LanceDB
|
|
234
|
+
Serverless vector database built on the Lance columnar format. **No Docker required.**
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
from gepa.adapters.generic_rag_adapter import LanceDBVectorStore
|
|
238
|
+
|
|
239
|
+
# Local LanceDB instance
|
|
240
|
+
vector_store = LanceDBVectorStore.create_local("./lancedb", "documents")
|
|
241
|
+
|
|
242
|
+
# In-memory (testing)
|
|
243
|
+
vector_store = LanceDBVectorStore.create_memory("documents")
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Adding New Vector Stores
|
|
247
|
+
|
|
248
|
+
Implement the `VectorStoreInterface` for your vector store:
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
class MyVectorStore(VectorStoreInterface):
|
|
252
|
+
def similarity_search(self, query: str, k: int = 5, filters=None):
|
|
253
|
+
# Your implementation
|
|
254
|
+
return documents
|
|
255
|
+
|
|
256
|
+
def vector_search(self, query_vector: List[float], k: int = 5, filters=None):
|
|
257
|
+
# Your implementation
|
|
258
|
+
return documents
|
|
259
|
+
|
|
260
|
+
def get_collection_info(self):
|
|
261
|
+
return {
|
|
262
|
+
"name": self.collection_name,
|
|
263
|
+
"document_count": self.count(),
|
|
264
|
+
"dimension": self.vector_dim,
|
|
265
|
+
"vector_store_type": "my_store"
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## 🎛️ Configuration Options
|
|
270
|
+
|
|
271
|
+
### Model Configuration
|
|
272
|
+
|
|
273
|
+
**Local Ollama Models (Recommended for Testing):**
|
|
274
|
+
```python
|
|
275
|
+
# Memory-friendly options
|
|
276
|
+
adapter = GenericRAGAdapter(
|
|
277
|
+
vector_store=vector_store,
|
|
278
|
+
llm_model="ollama/llama3.2:1b", # ~1GB RAM - Fast inference
|
|
279
|
+
rag_config=config
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
# Higher quality local models
|
|
283
|
+
adapter = GenericRAGAdapter(
|
|
284
|
+
vector_store=vector_store,
|
|
285
|
+
llm_model="ollama/llama3.1:8b", # ~5GB RAM - Better quality
|
|
286
|
+
rag_config=config
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
# GEPA optimization with local models
|
|
290
|
+
result = gepa.optimize(
|
|
291
|
+
seed_candidate=initial_prompts,
|
|
292
|
+
trainset=train_data,
|
|
293
|
+
valset=validation_data,
|
|
294
|
+
adapter=adapter,
|
|
295
|
+
max_metric_calls=5, # Small for local testing
|
|
296
|
+
reflection_llm_model="ollama/llama3.1:8b"
|
|
297
|
+
)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Cloud Models (Production Use):**
|
|
301
|
+
```python
|
|
302
|
+
# OpenAI models
|
|
303
|
+
adapter = GenericRAGAdapter(
|
|
304
|
+
vector_store=vector_store,
|
|
305
|
+
llm_model="gpt-4o", # Requires OPENAI_API_KEY
|
|
306
|
+
rag_config=config
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
# Anthropic models
|
|
310
|
+
adapter = GenericRAGAdapter(
|
|
311
|
+
vector_store=vector_store,
|
|
312
|
+
llm_model="claude-3-5-sonnet-20241022", # Requires ANTHROPIC_API_KEY
|
|
313
|
+
rag_config=config
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
# GEPA optimization with cloud models
|
|
317
|
+
result = gepa.optimize(
|
|
318
|
+
seed_candidate=initial_prompts,
|
|
319
|
+
trainset=train_data,
|
|
320
|
+
valset=validation_data,
|
|
321
|
+
adapter=adapter,
|
|
322
|
+
max_metric_calls=50, # Higher for production optimization
|
|
323
|
+
reflection_llm_model="gpt-4o"
|
|
324
|
+
)
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### RAG Pipeline Configuration
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
rag_config = {
|
|
331
|
+
# Retrieval Strategy
|
|
332
|
+
"retrieval_strategy": "similarity", # "similarity", "hybrid", "vector"
|
|
333
|
+
"top_k": 5, # Documents to retrieve
|
|
334
|
+
|
|
335
|
+
# Evaluation Weights
|
|
336
|
+
"retrieval_weight": 0.3, # Weight for retrieval metrics
|
|
337
|
+
"generation_weight": 0.7, # Weight for generation metrics
|
|
338
|
+
|
|
339
|
+
# Hybrid Search (Weaviate)
|
|
340
|
+
"hybrid_alpha": 0.5, # 0.0=keyword, 1.0=semantic, 0.5=balanced
|
|
341
|
+
|
|
342
|
+
# Filtering
|
|
343
|
+
"filters": {"category": "technical"} # Metadata filters
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
adapter = GenericRAGAdapter(
|
|
347
|
+
vector_store=vector_store,
|
|
348
|
+
llm_model="ollama/llama3.2:1b", # Local model for testing
|
|
349
|
+
# llm_model="gpt-4o", # For cloud-based usage
|
|
350
|
+
rag_config=rag_config
|
|
351
|
+
)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Advanced Configuration Examples
|
|
355
|
+
|
|
356
|
+
**ChromaDB Optimized:**
|
|
357
|
+
```python
|
|
358
|
+
config = {
|
|
359
|
+
"retrieval_strategy": "similarity",
|
|
360
|
+
"top_k": 7,
|
|
361
|
+
"retrieval_weight": 0.35,
|
|
362
|
+
"generation_weight": 0.65
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Weaviate with Hybrid Search:**
|
|
367
|
+
```python
|
|
368
|
+
config = {
|
|
369
|
+
"retrieval_strategy": "hybrid",
|
|
370
|
+
"top_k": 5,
|
|
371
|
+
"hybrid_alpha": 0.7, # More semantic than keyword
|
|
372
|
+
"retrieval_weight": 0.25,
|
|
373
|
+
"generation_weight": 0.75,
|
|
374
|
+
"filters": {"confidence": {"$gt": 0.8}}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## 🔍 Optimizable Components
|
|
379
|
+
|
|
380
|
+
### 1. Query Reformulation
|
|
381
|
+
Transform user queries for better retrieval:
|
|
382
|
+
|
|
383
|
+
```python
|
|
384
|
+
"query_reformulation": """
|
|
385
|
+
You are an expert at reformulating user queries for information retrieval.
|
|
386
|
+
Your task is to enhance the query while preserving the original intent.
|
|
387
|
+
|
|
388
|
+
Guidelines:
|
|
389
|
+
- Add relevant technical terms and synonyms
|
|
390
|
+
- Make the query more specific and focused
|
|
391
|
+
- Optimize for both semantic and keyword matching
|
|
392
|
+
- Preserve key concepts from the original query
|
|
393
|
+
|
|
394
|
+
Reformulate the following query for better retrieval:
|
|
395
|
+
"""
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### 2. Context Synthesis
|
|
399
|
+
Combine retrieved documents into coherent context:
|
|
400
|
+
|
|
401
|
+
```python
|
|
402
|
+
"context_synthesis": """
|
|
403
|
+
You are an expert at synthesizing information from multiple documents.
|
|
404
|
+
Your task is to create a comprehensive context that directly addresses the query.
|
|
405
|
+
|
|
406
|
+
Guidelines:
|
|
407
|
+
- Focus on information most relevant to the user's question
|
|
408
|
+
- Integrate information from multiple sources seamlessly
|
|
409
|
+
- Remove redundant or conflicting information
|
|
410
|
+
- Maintain factual accuracy and important details
|
|
411
|
+
|
|
412
|
+
Query: {query}
|
|
413
|
+
|
|
414
|
+
Synthesize the following retrieved documents:
|
|
415
|
+
"""
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### 3. Answer Generation
|
|
419
|
+
Generate accurate, well-structured final answers:
|
|
420
|
+
|
|
421
|
+
```python
|
|
422
|
+
"answer_generation": """
|
|
423
|
+
You are an AI assistant providing expert-level answers.
|
|
424
|
+
Your task is to generate accurate, comprehensive responses based on the provided context.
|
|
425
|
+
|
|
426
|
+
Guidelines:
|
|
427
|
+
- Base your answer primarily on the provided context
|
|
428
|
+
- Structure your response with clear explanations
|
|
429
|
+
- Include specific details and examples when available
|
|
430
|
+
- If context is insufficient, acknowledge the limitation clearly
|
|
431
|
+
|
|
432
|
+
Context: {context}
|
|
433
|
+
Question: {query}
|
|
434
|
+
|
|
435
|
+
Provide a thorough, accurate answer:
|
|
436
|
+
"""
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### 4. Document Reranking
|
|
440
|
+
Optimize retrieved document relevance ordering:
|
|
441
|
+
|
|
442
|
+
```python
|
|
443
|
+
"reranking_criteria": """
|
|
444
|
+
You are an expert at evaluating document relevance for question answering.
|
|
445
|
+
Your task is to rank documents by their relevance to the specific query.
|
|
446
|
+
|
|
447
|
+
Ranking Criteria:
|
|
448
|
+
- Documents with direct answers get highest priority
|
|
449
|
+
- Comprehensive explanations rank second
|
|
450
|
+
- Supporting examples and context rank third
|
|
451
|
+
- Off-topic or tangential content ranks lowest
|
|
452
|
+
|
|
453
|
+
Query: {query}
|
|
454
|
+
|
|
455
|
+
Rank these documents by relevance (most relevant first):
|
|
456
|
+
"""
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
## 📊 Evaluation Metrics
|
|
460
|
+
|
|
461
|
+
### Retrieval Quality Metrics
|
|
462
|
+
|
|
463
|
+
- **Precision**: Fraction of retrieved documents that are relevant
|
|
464
|
+
- **Recall**: Fraction of relevant documents that were retrieved
|
|
465
|
+
- **F1 Score**: Harmonic mean of precision and recall
|
|
466
|
+
- **MRR (Mean Reciprocal Rank)**: Quality of ranking for relevant documents
|
|
467
|
+
|
|
468
|
+
### Generation Quality Metrics
|
|
469
|
+
|
|
470
|
+
- **Exact Match**: Whether generated answer exactly matches ground truth
|
|
471
|
+
- **Token F1**: F1 score based on token overlap with ground truth
|
|
472
|
+
- **BLEU Score**: N-gram overlap similarity measure
|
|
473
|
+
- **Answer Relevance**: How well the answer relates to retrieved context
|
|
474
|
+
- **Faithfulness**: How well the answer is supported by the context
|
|
475
|
+
|
|
476
|
+
### Combined Scoring
|
|
477
|
+
|
|
478
|
+
The adapter computes a weighted combination of retrieval and generation metrics:
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
final_score = (retrieval_weight × retrieval_f1) + (generation_weight × generation_score)
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Where `generation_score` combines token F1, answer relevance, and faithfulness.
|
|
485
|
+
|
|
486
|
+
## 🚀 Production Examples
|
|
487
|
+
|
|
488
|
+
### Multi-Vector Store Deployment
|
|
489
|
+
|
|
490
|
+
```python
|
|
491
|
+
def create_rag_adapter(env: str):
|
|
492
|
+
if env == "development":
|
|
493
|
+
vector_store = ChromaVectorStore.create_local("./local_kb", "docs")
|
|
494
|
+
config = {"retrieval_strategy": "similarity", "top_k": 3}
|
|
495
|
+
llm_model = "ollama/llama3.2:1b" # Memory-friendly for local dev
|
|
496
|
+
elif env == "production":
|
|
497
|
+
vector_store = WeaviateVectorStore.create_cloud(
|
|
498
|
+
cluster_url=os.getenv("WEAVIATE_URL"),
|
|
499
|
+
auth_credentials=weaviate.AuthApiKey(os.getenv("WEAVIATE_KEY")),
|
|
500
|
+
collection_name="ProductionKB"
|
|
501
|
+
)
|
|
502
|
+
config = {
|
|
503
|
+
"retrieval_strategy": "hybrid",
|
|
504
|
+
"hybrid_alpha": 0.75,
|
|
505
|
+
"top_k": 5,
|
|
506
|
+
"filters": {"status": "approved"}
|
|
507
|
+
}
|
|
508
|
+
llm_model = os.getenv("LLM_MODEL", "gpt-4o") # Cloud models for production
|
|
509
|
+
|
|
510
|
+
return GenericRAGAdapter(
|
|
511
|
+
vector_store=vector_store,
|
|
512
|
+
llm_model=llm_model,
|
|
513
|
+
rag_config=config
|
|
514
|
+
)
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Performance Monitoring
|
|
518
|
+
|
|
519
|
+
```python
|
|
520
|
+
# Enable detailed tracing for analysis
|
|
521
|
+
eval_batch = adapter.evaluate(
|
|
522
|
+
batch=test_data,
|
|
523
|
+
candidate=optimized_prompts,
|
|
524
|
+
capture_traces=True
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
# Analyze performance
|
|
528
|
+
for i, (trajectory, score) in enumerate(zip(eval_batch.trajectories, eval_batch.scores)):
|
|
529
|
+
print(f"Query {i+1}: Score = {score:.3f}")
|
|
530
|
+
print(f" Retrieved: {len(trajectory['retrieved_docs'])} documents")
|
|
531
|
+
print(f" Token usage: {trajectory['execution_metadata']['total_tokens']}")
|
|
532
|
+
|
|
533
|
+
# Access detailed metrics
|
|
534
|
+
retrieval_metrics = trajectory['execution_metadata']['retrieval_metrics']
|
|
535
|
+
generation_metrics = trajectory['execution_metadata']['generation_metrics']
|
|
536
|
+
|
|
537
|
+
print(f" Retrieval F1: {retrieval_metrics['retrieval_f1']:.3f}")
|
|
538
|
+
print(f" Generation F1: {generation_metrics['token_f1']:.3f}")
|
|
539
|
+
print(f" Faithfulness: {generation_metrics['faithfulness']:.3f}")
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
## 📚 Complete Examples
|
|
543
|
+
|
|
544
|
+
### Unified RAG Optimization Script
|
|
545
|
+
We've consolidated all vector database examples into a single, unified script in `src/gepa/examples/rag_adapter/`:
|
|
546
|
+
|
|
547
|
+
- **[Unified RAG Optimization](examples/rag_adapter/rag_optimization.py)** - One script supporting all vector stores
|
|
548
|
+
- ChromaDB - Local development, no Docker required
|
|
549
|
+
- Weaviate - Production deployment with hybrid search
|
|
550
|
+
- Qdrant - High performance with advanced filtering
|
|
551
|
+
- Milvus - Cloud-native with Milvus Lite
|
|
552
|
+
- LanceDB - Serverless, developer-friendly
|
|
553
|
+
|
|
554
|
+
### Quick Start Guide
|
|
555
|
+
- **[RAG_GUIDE.md](examples/rag_adapter/RAG_GUIDE.md)** - Comprehensive setup instructions for the unified approach
|
|
556
|
+
- **[requirements-rag.txt](examples/rag_adapter/requirements-rag.txt)** - All vector store dependencies in one file
|
|
557
|
+
- **Docker Requirements** - Clear guidance on which vector stores need Docker vs. which don't
|
|
558
|
+
- **Model Recommendations** - Performance expectations and use cases for each database
|
|
559
|
+
|
|
560
|
+
## 🤝 Contributing
|
|
561
|
+
|
|
562
|
+
We welcome contributions! Priority areas:
|
|
563
|
+
|
|
564
|
+
### New Vector Store Implementations
|
|
565
|
+
- **Pinecone**: Managed vector database with high performance
|
|
566
|
+
- **Elasticsearch**: Search engine with vector capabilities
|
|
567
|
+
- **OpenSearch**: Open-source alternative to Elasticsearch
|
|
568
|
+
- **FAISS**: Facebook AI Similarity Search
|
|
569
|
+
- **Annoy**: Approximate Nearest Neighbors
|
|
570
|
+
|
|
571
|
+
**Already Implemented:**
|
|
572
|
+
- ✅ **ChromaDB** - Local development and prototyping
|
|
573
|
+
- ✅ **Weaviate** - Production-grade with hybrid search
|
|
574
|
+
- ✅ **Qdrant** - High performance with advanced filtering
|
|
575
|
+
- ✅ **Milvus** - Cloud-native with Milvus Lite support
|
|
576
|
+
- ✅ **LanceDB** - Serverless, developer-friendly
|
|
577
|
+
|
|
578
|
+
### Enhancement Areas
|
|
579
|
+
- Advanced reranking algorithms (learning-to-rank, neural rerankers)
|
|
580
|
+
- Multi-modal RAG support (text + images)
|
|
581
|
+
- Streaming evaluation for large datasets
|
|
582
|
+
- Integration with embedding providers (OpenAI, Cohere, HuggingFace)
|
|
583
|
+
- Performance optimizations and caching strategies
|
|
584
|
+
|
|
585
|
+
### Implementation Guidelines
|
|
586
|
+
|
|
587
|
+
1. **Follow the Interface**: Implement `VectorStoreInterface` completely
|
|
588
|
+
2. **Add Factory Methods**: Provide `create_local()`, `create_cloud()` class methods
|
|
589
|
+
3. **Error Handling**: Graceful degradation and clear error messages
|
|
590
|
+
4. **Documentation**: Comprehensive docstrings and usage examples
|
|
591
|
+
5. **Testing**: Unit tests for all public methods
|
|
592
|
+
|
|
593
|
+
See our [contribution guide](CONTRIBUTING.md) for detailed instructions.
|
|
594
|
+
|
|
595
|
+
## 📄 API Reference
|
|
596
|
+
|
|
597
|
+
### Core Classes
|
|
598
|
+
|
|
599
|
+
- **[`GenericRAGAdapter`](generic_rag_adapter.py)**: Main adapter class for GEPA integration
|
|
600
|
+
- **[`VectorStoreInterface`](vector_store_interface.py)**: Abstract base class for vector stores
|
|
601
|
+
- **[`RAGPipeline`](rag_pipeline.py)**: RAG execution engine
|
|
602
|
+
- **[`RAGEvaluationMetrics`](evaluation_metrics.py)**: Comprehensive evaluation metrics
|
|
603
|
+
|
|
604
|
+
### Vector Store Implementations
|
|
605
|
+
|
|
606
|
+
- **[`ChromaVectorStore`](vector_stores/chroma_store.py)**: ChromaDB implementation
|
|
607
|
+
- **[`WeaviateVectorStore`](vector_stores/weaviate_store.py)**: Weaviate implementation
|
|
608
|
+
- **[`QdrantVectorStore`](vector_stores/qdrant_store.py)**: Qdrant implementation
|
|
609
|
+
- **[`MilvusVectorStore`](vector_stores/milvus_store.py)**: Milvus implementation
|
|
610
|
+
- **[`LanceDBVectorStore`](vector_stores/lancedb_store.py)**: LanceDB implementation
|
|
611
|
+
|
|
612
|
+
### Type Definitions
|
|
613
|
+
|
|
614
|
+
- **`RAGDataInst`**: Training/validation example structure
|
|
615
|
+
- **`RAGTrajectory`**: Detailed execution trace
|
|
616
|
+
- **`RAGOutput`**: Final system output with metadata
|
|
617
|
+
|
|
618
|
+
## 🔒 License
|
|
619
|
+
|
|
620
|
+
Copyright (c) 2025 Lakshya A Agrawal and the GEPA contributors
|
|
621
|
+
Licensed under the MIT License - see [LICENSE](../../../LICENSE) for details.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright (c) 2025 Lakshya A Agrawal and the GEPA contributors
|
|
2
|
+
# https://github.com/gepa-ai/gepa
|
|
3
|
+
|
|
4
|
+
from .evaluation_metrics import RAGEvaluationMetrics
|
|
5
|
+
from .generic_rag_adapter import (
|
|
6
|
+
GenericRAGAdapter,
|
|
7
|
+
RAGDataInst,
|
|
8
|
+
RAGOutput,
|
|
9
|
+
RAGTrajectory,
|
|
10
|
+
)
|
|
11
|
+
from .rag_pipeline import RAGPipeline
|
|
12
|
+
from .vector_store_interface import VectorStoreInterface
|
|
13
|
+
from .vector_stores.chroma_store import ChromaVectorStore
|
|
14
|
+
from .vector_stores.weaviate_store import WeaviateVectorStore
|
|
15
|
+
|
|
16
|
+
# Optional vector stores - import only if dependencies are available
|
|
17
|
+
try:
|
|
18
|
+
from .vector_stores.qdrant_store import QdrantVectorStore
|
|
19
|
+
|
|
20
|
+
_QDRANT_AVAILABLE = True
|
|
21
|
+
except ImportError:
|
|
22
|
+
_QDRANT_AVAILABLE = False
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from .vector_stores.milvus_store import MilvusVectorStore
|
|
26
|
+
|
|
27
|
+
_MILVUS_AVAILABLE = True
|
|
28
|
+
except ImportError:
|
|
29
|
+
_MILVUS_AVAILABLE = False
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
from .vector_stores.lancedb_store import LanceDBVectorStore
|
|
33
|
+
|
|
34
|
+
_LANCEDB_AVAILABLE = True
|
|
35
|
+
except ImportError:
|
|
36
|
+
_LANCEDB_AVAILABLE = False
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"GenericRAGAdapter",
|
|
40
|
+
"RAGDataInst",
|
|
41
|
+
"RAGOutput",
|
|
42
|
+
"RAGTrajectory",
|
|
43
|
+
"VectorStoreInterface",
|
|
44
|
+
"ChromaVectorStore",
|
|
45
|
+
"WeaviateVectorStore",
|
|
46
|
+
"RAGPipeline",
|
|
47
|
+
"RAGEvaluationMetrics",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
# Add optional vector stores to __all__ if available
|
|
51
|
+
if _QDRANT_AVAILABLE:
|
|
52
|
+
__all__.append("QdrantVectorStore")
|
|
53
|
+
if _MILVUS_AVAILABLE:
|
|
54
|
+
__all__.append("MilvusVectorStore")
|
|
55
|
+
if _LANCEDB_AVAILABLE:
|
|
56
|
+
__all__.append("LanceDBVectorStore")
|