vectorwave 0.2.8__tar.gz → 0.3.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.
- vectorwave-0.3.0/PKG-INFO +258 -0
- vectorwave-0.3.0/Readme.md +229 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/pyproject.toml +4 -2
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/__init__.py +3 -2
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/batch/batch.py +23 -5
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/auto_injector.py +1 -1
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/decorator.py +57 -33
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/generator.py +2 -2
- vectorwave-0.3.0/src/vectorwave/core/initializer.py +37 -0
- vectorwave-0.3.0/src/vectorwave/core/llm/factory.py +10 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/database/dataset.py +10 -2
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/database/db.py +127 -98
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/database/db_search.py +4 -4
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/models/db_config.py +21 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/tracer.py +203 -171
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/search/execution_search.py +2 -20
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/search/rag_search.py +2 -2
- vectorwave-0.3.0/src/vectorwave/utils/github_pr.py +87 -0
- vectorwave-0.3.0/src/vectorwave/utils/healer.py +330 -0
- vectorwave-0.3.0/src/vectorwave/utils/path_utils.py +32 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/utils/replayer.py +73 -51
- vectorwave-0.3.0/src/vectorwave/utils/replayer_semantic.py +130 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/utils/return_caching_utils.py +2 -1
- vectorwave-0.3.0/src/vectorwave/utils/scheduler.py +127 -0
- vectorwave-0.3.0/src/vectorwave/utils/serialization.py +17 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/utils/status.py +0 -4
- vectorwave-0.2.8/PKG-INFO +0 -60
- vectorwave-0.2.8/Readme.md +0 -33
- vectorwave-0.2.8/src/vectorwave/core/llm/factory.py +0 -13
- vectorwave-0.2.8/src/vectorwave/utils/healer.py +0 -155
- vectorwave-0.2.8/src/vectorwave/utils/replayer_semantic.py +0 -234
- {vectorwave-0.2.8 → vectorwave-0.3.0}/crates/Cargo.lock +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/crates/Cargo.toml +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/crates/src/lib.rs +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/batch/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/core.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/llm/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/llm/base.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/core/llm/openai_client.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/database/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/database/archiver.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/exception/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/exception/exceptions.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/models/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/alert/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/alert/base.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/alert/factory.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/alert/null_alerter.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/alert/webhook_alerter.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/monitoring/monitoring.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/prediction/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/prediction/predictor.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/search/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/search/extended_search.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/utils/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/utils/context.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/utils/function_cache.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/vectorizer/__init__.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/vectorizer/base.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/vectorizer/factory.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/vectorizer/huggingface_vectorizer.py +0 -0
- {vectorwave-0.2.8 → vectorwave-0.3.0}/src/vectorwave/vectorizer/openai_vectorizer.py +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vectorwave
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Classifier: Programming Language :: Python :: 3
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Programming Language :: Rust
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Requires-Dist: weaviate-client>=4.0.0
|
|
14
|
+
Requires-Dist: pydantic-settings>=2.0.0
|
|
15
|
+
Requires-Dist: sentence-transformers
|
|
16
|
+
Requires-Dist: requests
|
|
17
|
+
Requires-Dist: openai
|
|
18
|
+
Requires-Dist: pygithub
|
|
19
|
+
Requires-Dist: schedule
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: NOTICE
|
|
22
|
+
Summary: VectorWave: Seamless Auto-Vectorization Framework
|
|
23
|
+
Author-email: junyeonggim <junyeonggim5@gmail.com>
|
|
24
|
+
License-Expression: MIT
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
27
|
+
Project-URL: Repository, https://github.com/cozymori/vectorwave
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
Need more information? Visit [here](https://www.cozymori.net/vectorwave)
|
|
33
|
+
|
|
34
|
+
# VectorWave
|
|
35
|
+

|
|
36
|
+

|
|
37
|
+

|
|
38
|
+

|
|
39
|
+

|
|
40
|
+

|
|
41
|
+

|
|
42
|
+

|
|
43
|
+

|
|
44
|
+
<br>**Seamless Auto-Vectorization Framework**
|
|
45
|
+
|
|
46
|
+
We transform volatile data that disappears the moment code is executed into a Searchable and Reusable permanent knowledge asset.
|
|
47
|
+
|
|
48
|
+
### Requirements
|
|
49
|
+
|
|
50
|
+
* **Python**: 3.10 ~ 3.13
|
|
51
|
+
* **Docker**: Required to run the Weaviate database.
|
|
52
|
+
* (Optional) **OpenAI API Key**: Required for AI auto-documentation and high-performance embedding.
|
|
53
|
+
|
|
54
|
+
### How to reach us
|
|
55
|
+
|
|
56
|
+
Have questions or found a bug? Please join our community.
|
|
57
|
+
|
|
58
|
+
* **GitHub Issues**: [https://github.com/cozymori/vectorwave/issues](https://github.com/cozymori/vectorwave/issues)
|
|
59
|
+
|
|
60
|
+
### Contributors
|
|
61
|
+
[See the contributors of vectorwave](https://github.com/Cozymori/VectorWave/graphs/contributors)<br>
|
|
62
|
+
VectorWave is an open-source project and we welcome your contributions.
|
|
63
|
+
Please refer to [CONTRIBUTING.md](https://www.google.com/search?q=https://github.com/cozymori/vectorwave/blob/main/CONTRIBUTING.md) in the GitHub repository.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 🚀 What is VectorWave?
|
|
68
|
+
|
|
69
|
+
**VectorWave** is a unified framework designed to solve the "Efficiency vs. Reliability" dilemma in LLM-integrated applications. It introduces a new paradigm of **Execution-Level Semantic Optimization** combined with **Autonomous Self-Healing**.
|
|
70
|
+
|
|
71
|
+
Unlike conventional semantic caching tools that primarily focus on text similarity, **VectorWave** captures the entire **Function Execution Context**. It creates a permanent "Golden Dataset" from your successful executions and uses it to:
|
|
72
|
+
|
|
73
|
+
1. **Slash Costs**: Serve cached results for semantically similar inputs, bypassing expensive computations.
|
|
74
|
+
2. **Fix Bugs**: Automatically diagnose runtime errors and generate GitHub PRs using LLM.
|
|
75
|
+
3. **Monitor Quality**: Detect when user inputs start drifting away from known patterns (Semantic Drift).
|
|
76
|
+
|
|
77
|
+
## Architecture
|
|
78
|
+
|
|
79
|
+
VectorWave operates as a transparent layer between your application and the LLM/Infrastructure, handling everything from vectorization to GitOps automation.
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
### Core Components
|
|
84
|
+
* **Optimization Engine**: Intercepts function calls to check for semantic cache hits using HNSW indexes.
|
|
85
|
+
* **Trace Context Manager**: Collects execution logs, inputs, and outputs without modifying your code structure.
|
|
86
|
+
* **Self-Healing Pipeline**: An autonomous agent that wakes up on errors, diagnoses the root cause, and submits patches.
|
|
87
|
+
|
|
88
|
+
## 😊 Quick Start
|
|
89
|
+
|
|
90
|
+
You can attach VectorWave to any Python function using a simple decorator.
|
|
91
|
+
|
|
92
|
+
### 1. Prerequisites (Start Vector DB)
|
|
93
|
+
|
|
94
|
+
VectorWave requires a Vector Database (Weaviate) to store execution contexts.
|
|
95
|
+
Create a `docker-compose.yml` file and start the service:
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
# docker-compose.yml
|
|
99
|
+
version: '3.4'
|
|
100
|
+
services:
|
|
101
|
+
weaviate:
|
|
102
|
+
command:
|
|
103
|
+
- --host
|
|
104
|
+
- 0.0.0.0
|
|
105
|
+
- --port
|
|
106
|
+
- '8080'
|
|
107
|
+
- --scheme
|
|
108
|
+
- http
|
|
109
|
+
image: semitechnologies/weaviate:1.26.1
|
|
110
|
+
ports:
|
|
111
|
+
- 8080:8080
|
|
112
|
+
- 50051:50051
|
|
113
|
+
restart: on-failure:0
|
|
114
|
+
environment:
|
|
115
|
+
QUERY_DEFAULTS_LIMIT: 25
|
|
116
|
+
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
|
|
117
|
+
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
|
|
118
|
+
DEFAULT_VECTORIZER_MODULE: 'none'
|
|
119
|
+
ENABLE_MODULES: 'text2vec-openai,generative-openai'
|
|
120
|
+
CLUSTER_HOSTNAME: 'node1'
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Run the container:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
docker-compose up -d
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 2. Install VectorWave
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pip install vectorwave
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3. Basic Usage (Semantic Caching)
|
|
139
|
+
|
|
140
|
+
Now, apply the `@vectorize` decorator to your functions.
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
import time
|
|
144
|
+
from vectorwave import vectorize, initialize_database
|
|
145
|
+
|
|
146
|
+
# 1. (Optional) Set up your OpenAI Key for vectorization
|
|
147
|
+
# os.environ["OPENAI_API_KEY"] = "sk-..."
|
|
148
|
+
|
|
149
|
+
initialize_database()
|
|
150
|
+
|
|
151
|
+
# 2. Just add the @vectorize decorator!
|
|
152
|
+
@vectorize(semantic_cache=True, cache_threshold=0.95, auto=True)
|
|
153
|
+
def expensive_llm_task(query: str):
|
|
154
|
+
# Simulate a slow and expensive API call
|
|
155
|
+
time.sleep(2)
|
|
156
|
+
return f"Processed result for: {query}"
|
|
157
|
+
|
|
158
|
+
# First call: Runs the function (Cache Miss) -> Took 2.0s
|
|
159
|
+
print(expensive_llm_task("How do I fix a Python bug?"))
|
|
160
|
+
|
|
161
|
+
# Second call: Returns from Weaviate DB (Cache Hit) -> Took 0.02s!
|
|
162
|
+
# Even if the query is slightly different but semantically same.
|
|
163
|
+
print(expensive_llm_task("Tell me how to debug Python code."))
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 4. Self-Healing in Action
|
|
168
|
+
|
|
169
|
+
When your code breaks, VectorWave actively fixes it.
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
# Suppose this function has a bug (ZeroDivisionError)
|
|
173
|
+
@vectorize(auto=True)
|
|
174
|
+
def risky_calculation(a, b):
|
|
175
|
+
return a / b
|
|
176
|
+
|
|
177
|
+
# Triggering an error
|
|
178
|
+
risky_calculation(10, 0)
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**What happens next?**
|
|
183
|
+
|
|
184
|
+
1. **Detection**: The `AutoHealerBot` detects the `ZeroDivisionError`.
|
|
185
|
+
2. **Diagnosis**: It retrieves the source code and error stack trace.
|
|
186
|
+
3. **Fix**: It uses an LLM to generate a patch (adding `try-except` or input validation).
|
|
187
|
+
4. **Action**: A **Pull Request** is automatically created in your GitHub repository.
|
|
188
|
+
|
|
189
|
+

|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
## Key Features
|
|
193
|
+
|
|
194
|
+
### ⚡ Optimization Engine (Semantic Caching)
|
|
195
|
+
|
|
196
|
+
Don't pay for the same computation twice. VectorWave uses **Weaviate** vector database to store and retrieve function results based on meaning, not just exact string matching.
|
|
197
|
+
|
|
198
|
+
* **Latency**: Reduced from seconds to milliseconds.
|
|
199
|
+
* **Cost**: Up to 90% reduction in LLM token usage.
|
|
200
|
+
|
|
201
|
+

|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
### Self-Healing & GitOps
|
|
205
|
+
|
|
206
|
+
VectorWave doesn't just log errors; it acts on them.
|
|
207
|
+
|
|
208
|
+
* **Automated Root Cause Analysis (RCA)** using RAG.
|
|
209
|
+
* **GitOps Integration**: Generates actual code fixes and pushes them to a new branch.
|
|
210
|
+
* **Cooldown Mechanism**: Prevents spamming PRs for the same error.
|
|
211
|
+
|
|
212
|
+
### Semantic Drift Radar
|
|
213
|
+
|
|
214
|
+
Detect when your users are asking things your model wasn't designed for.
|
|
215
|
+
|
|
216
|
+
* **Anomaly Detection**: Calculates the distance between new queries and your "Golden Dataset".
|
|
217
|
+
* **Alerting**: Sends notifications (e.g., Discord) when drift exceeds the threshold (default 0.25).
|
|
218
|
+
|
|
219
|
+

|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
## How does it work?
|
|
223
|
+
|
|
224
|
+
Unlike traditional Key-Value caching (e.g., Redis), VectorWave understands **Context**.
|
|
225
|
+
|
|
226
|
+
1. **Vectorization**: It converts function arguments into high-dimensional vectors using OpenAI or HuggingFace models.
|
|
227
|
+
2. **Search**: It performs an Approximate Nearest Neighbor (ANN) search in the vector store.
|
|
228
|
+
3. **Decision**:
|
|
229
|
+
* If a neighbor is found within the `threshold` -> **Return Cached Result**.
|
|
230
|
+
* If not -> **Execute Function** -> **Async Log to DB**.
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
## Performance Benchmark
|
|
235
|
+
|
|
236
|
+
| Metric | Direct Execution | With VectorWave | Improvement |
|
|
237
|
+
| --- | --- | --- | --- |
|
|
238
|
+
| **Latency (Hit)** | ~2.5s (LLM API) | **~0.02s** | **125x Faster** |
|
|
239
|
+
| **Cost (Hit)** | $0.03 / call | **$0.00** | **100% Savings** |
|
|
240
|
+
| **Reliability** | Manual Fix Required | **Auto-PR Created** | **Autonomous** |
|
|
241
|
+
|
|
242
|
+
## Feature Comparison
|
|
243
|
+
|
|
244
|
+
Why choose VectorWave over traditional semantic caches?
|
|
245
|
+
|
|
246
|
+
| Feature | Traditional Tools (e.g., GPTCache) | **VectorWave** |
|
|
247
|
+
| :--- | :---: | :---: |
|
|
248
|
+
| **Semantic Caching** | O (Text-based) | **O (Execution Context)** |
|
|
249
|
+
| **Self-Healing (Auto-Fix)** | X | **O (Autonomous)** |
|
|
250
|
+
| **GitOps (Auto-PR)** | X | **O (Seamless)** |
|
|
251
|
+
| **Semantic Drift Detection** | X | **O (Drift Radar)** |
|
|
252
|
+
| **Zero-Config Setup** | △ (Setup Required) | **O (Decorator)** |
|
|
253
|
+
|
|
254
|
+
## 😍 Contributing
|
|
255
|
+
|
|
256
|
+
We are extremely open to contributions! Whether it's a new vectorizer, a better healing prompt, or just a typo fix.
|
|
257
|
+
Please check our [Contribution Guide](./Contributing.md).
|
|
258
|
+
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
Need more information? Visit [here](https://www.cozymori.net/vectorwave)
|
|
5
|
+
|
|
6
|
+
# VectorWave
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+
<br>**Seamless Auto-Vectorization Framework**
|
|
17
|
+
|
|
18
|
+
We transform volatile data that disappears the moment code is executed into a Searchable and Reusable permanent knowledge asset.
|
|
19
|
+
|
|
20
|
+
### Requirements
|
|
21
|
+
|
|
22
|
+
* **Python**: 3.10 ~ 3.13
|
|
23
|
+
* **Docker**: Required to run the Weaviate database.
|
|
24
|
+
* (Optional) **OpenAI API Key**: Required for AI auto-documentation and high-performance embedding.
|
|
25
|
+
|
|
26
|
+
### How to reach us
|
|
27
|
+
|
|
28
|
+
Have questions or found a bug? Please join our community.
|
|
29
|
+
|
|
30
|
+
* **GitHub Issues**: [https://github.com/cozymori/vectorwave/issues](https://github.com/cozymori/vectorwave/issues)
|
|
31
|
+
|
|
32
|
+
### Contributors
|
|
33
|
+
[See the contributors of vectorwave](https://github.com/Cozymori/VectorWave/graphs/contributors)<br>
|
|
34
|
+
VectorWave is an open-source project and we welcome your contributions.
|
|
35
|
+
Please refer to [CONTRIBUTING.md](https://www.google.com/search?q=https://github.com/cozymori/vectorwave/blob/main/CONTRIBUTING.md) in the GitHub repository.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🚀 What is VectorWave?
|
|
40
|
+
|
|
41
|
+
**VectorWave** is a unified framework designed to solve the "Efficiency vs. Reliability" dilemma in LLM-integrated applications. It introduces a new paradigm of **Execution-Level Semantic Optimization** combined with **Autonomous Self-Healing**.
|
|
42
|
+
|
|
43
|
+
Unlike conventional semantic caching tools that primarily focus on text similarity, **VectorWave** captures the entire **Function Execution Context**. It creates a permanent "Golden Dataset" from your successful executions and uses it to:
|
|
44
|
+
|
|
45
|
+
1. **Slash Costs**: Serve cached results for semantically similar inputs, bypassing expensive computations.
|
|
46
|
+
2. **Fix Bugs**: Automatically diagnose runtime errors and generate GitHub PRs using LLM.
|
|
47
|
+
3. **Monitor Quality**: Detect when user inputs start drifting away from known patterns (Semantic Drift).
|
|
48
|
+
|
|
49
|
+
## Architecture
|
|
50
|
+
|
|
51
|
+
VectorWave operates as a transparent layer between your application and the LLM/Infrastructure, handling everything from vectorization to GitOps automation.
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
### Core Components
|
|
56
|
+
* **Optimization Engine**: Intercepts function calls to check for semantic cache hits using HNSW indexes.
|
|
57
|
+
* **Trace Context Manager**: Collects execution logs, inputs, and outputs without modifying your code structure.
|
|
58
|
+
* **Self-Healing Pipeline**: An autonomous agent that wakes up on errors, diagnoses the root cause, and submits patches.
|
|
59
|
+
|
|
60
|
+
## 😊 Quick Start
|
|
61
|
+
|
|
62
|
+
You can attach VectorWave to any Python function using a simple decorator.
|
|
63
|
+
|
|
64
|
+
### 1. Prerequisites (Start Vector DB)
|
|
65
|
+
|
|
66
|
+
VectorWave requires a Vector Database (Weaviate) to store execution contexts.
|
|
67
|
+
Create a `docker-compose.yml` file and start the service:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
# docker-compose.yml
|
|
71
|
+
version: '3.4'
|
|
72
|
+
services:
|
|
73
|
+
weaviate:
|
|
74
|
+
command:
|
|
75
|
+
- --host
|
|
76
|
+
- 0.0.0.0
|
|
77
|
+
- --port
|
|
78
|
+
- '8080'
|
|
79
|
+
- --scheme
|
|
80
|
+
- http
|
|
81
|
+
image: semitechnologies/weaviate:1.26.1
|
|
82
|
+
ports:
|
|
83
|
+
- 8080:8080
|
|
84
|
+
- 50051:50051
|
|
85
|
+
restart: on-failure:0
|
|
86
|
+
environment:
|
|
87
|
+
QUERY_DEFAULTS_LIMIT: 25
|
|
88
|
+
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
|
|
89
|
+
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
|
|
90
|
+
DEFAULT_VECTORIZER_MODULE: 'none'
|
|
91
|
+
ENABLE_MODULES: 'text2vec-openai,generative-openai'
|
|
92
|
+
CLUSTER_HOSTNAME: 'node1'
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Run the container:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
docker-compose up -d
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 2. Install VectorWave
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install vectorwave
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 3. Basic Usage (Semantic Caching)
|
|
111
|
+
|
|
112
|
+
Now, apply the `@vectorize` decorator to your functions.
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
import time
|
|
116
|
+
from vectorwave import vectorize, initialize_database
|
|
117
|
+
|
|
118
|
+
# 1. (Optional) Set up your OpenAI Key for vectorization
|
|
119
|
+
# os.environ["OPENAI_API_KEY"] = "sk-..."
|
|
120
|
+
|
|
121
|
+
initialize_database()
|
|
122
|
+
|
|
123
|
+
# 2. Just add the @vectorize decorator!
|
|
124
|
+
@vectorize(semantic_cache=True, cache_threshold=0.95, auto=True)
|
|
125
|
+
def expensive_llm_task(query: str):
|
|
126
|
+
# Simulate a slow and expensive API call
|
|
127
|
+
time.sleep(2)
|
|
128
|
+
return f"Processed result for: {query}"
|
|
129
|
+
|
|
130
|
+
# First call: Runs the function (Cache Miss) -> Took 2.0s
|
|
131
|
+
print(expensive_llm_task("How do I fix a Python bug?"))
|
|
132
|
+
|
|
133
|
+
# Second call: Returns from Weaviate DB (Cache Hit) -> Took 0.02s!
|
|
134
|
+
# Even if the query is slightly different but semantically same.
|
|
135
|
+
print(expensive_llm_task("Tell me how to debug Python code."))
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 4. Self-Healing in Action
|
|
140
|
+
|
|
141
|
+
When your code breaks, VectorWave actively fixes it.
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
# Suppose this function has a bug (ZeroDivisionError)
|
|
145
|
+
@vectorize(auto=True)
|
|
146
|
+
def risky_calculation(a, b):
|
|
147
|
+
return a / b
|
|
148
|
+
|
|
149
|
+
# Triggering an error
|
|
150
|
+
risky_calculation(10, 0)
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**What happens next?**
|
|
155
|
+
|
|
156
|
+
1. **Detection**: The `AutoHealerBot` detects the `ZeroDivisionError`.
|
|
157
|
+
2. **Diagnosis**: It retrieves the source code and error stack trace.
|
|
158
|
+
3. **Fix**: It uses an LLM to generate a patch (adding `try-except` or input validation).
|
|
159
|
+
4. **Action**: A **Pull Request** is automatically created in your GitHub repository.
|
|
160
|
+
|
|
161
|
+

|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## Key Features
|
|
165
|
+
|
|
166
|
+
### ⚡ Optimization Engine (Semantic Caching)
|
|
167
|
+
|
|
168
|
+
Don't pay for the same computation twice. VectorWave uses **Weaviate** vector database to store and retrieve function results based on meaning, not just exact string matching.
|
|
169
|
+
|
|
170
|
+
* **Latency**: Reduced from seconds to milliseconds.
|
|
171
|
+
* **Cost**: Up to 90% reduction in LLM token usage.
|
|
172
|
+
|
|
173
|
+

|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
### Self-Healing & GitOps
|
|
177
|
+
|
|
178
|
+
VectorWave doesn't just log errors; it acts on them.
|
|
179
|
+
|
|
180
|
+
* **Automated Root Cause Analysis (RCA)** using RAG.
|
|
181
|
+
* **GitOps Integration**: Generates actual code fixes and pushes them to a new branch.
|
|
182
|
+
* **Cooldown Mechanism**: Prevents spamming PRs for the same error.
|
|
183
|
+
|
|
184
|
+
### Semantic Drift Radar
|
|
185
|
+
|
|
186
|
+
Detect when your users are asking things your model wasn't designed for.
|
|
187
|
+
|
|
188
|
+
* **Anomaly Detection**: Calculates the distance between new queries and your "Golden Dataset".
|
|
189
|
+
* **Alerting**: Sends notifications (e.g., Discord) when drift exceeds the threshold (default 0.25).
|
|
190
|
+
|
|
191
|
+

|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
## How does it work?
|
|
195
|
+
|
|
196
|
+
Unlike traditional Key-Value caching (e.g., Redis), VectorWave understands **Context**.
|
|
197
|
+
|
|
198
|
+
1. **Vectorization**: It converts function arguments into high-dimensional vectors using OpenAI or HuggingFace models.
|
|
199
|
+
2. **Search**: It performs an Approximate Nearest Neighbor (ANN) search in the vector store.
|
|
200
|
+
3. **Decision**:
|
|
201
|
+
* If a neighbor is found within the `threshold` -> **Return Cached Result**.
|
|
202
|
+
* If not -> **Execute Function** -> **Async Log to DB**.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## Performance Benchmark
|
|
207
|
+
|
|
208
|
+
| Metric | Direct Execution | With VectorWave | Improvement |
|
|
209
|
+
| --- | --- | --- | --- |
|
|
210
|
+
| **Latency (Hit)** | ~2.5s (LLM API) | **~0.02s** | **125x Faster** |
|
|
211
|
+
| **Cost (Hit)** | $0.03 / call | **$0.00** | **100% Savings** |
|
|
212
|
+
| **Reliability** | Manual Fix Required | **Auto-PR Created** | **Autonomous** |
|
|
213
|
+
|
|
214
|
+
## Feature Comparison
|
|
215
|
+
|
|
216
|
+
Why choose VectorWave over traditional semantic caches?
|
|
217
|
+
|
|
218
|
+
| Feature | Traditional Tools (e.g., GPTCache) | **VectorWave** |
|
|
219
|
+
| :--- | :---: | :---: |
|
|
220
|
+
| **Semantic Caching** | O (Text-based) | **O (Execution Context)** |
|
|
221
|
+
| **Self-Healing (Auto-Fix)** | X | **O (Autonomous)** |
|
|
222
|
+
| **GitOps (Auto-PR)** | X | **O (Seamless)** |
|
|
223
|
+
| **Semantic Drift Detection** | X | **O (Drift Radar)** |
|
|
224
|
+
| **Zero-Config Setup** | △ (Setup Required) | **O (Decorator)** |
|
|
225
|
+
|
|
226
|
+
## 😍 Contributing
|
|
227
|
+
|
|
228
|
+
We are extremely open to contributions! Whether it's a new vectorizer, a better healing prompt, or just a typo fix.
|
|
229
|
+
Please check our [Contribution Guide](./Contributing.md).
|
|
@@ -5,7 +5,7 @@ build-backend = "maturin"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "vectorwave"
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "0.3.0"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "junyeonggim", email = "junyeonggim5@gmail.com" },
|
|
11
11
|
]
|
|
@@ -30,7 +30,9 @@ dependencies = [
|
|
|
30
30
|
"pydantic-settings>=2.0.0",
|
|
31
31
|
"sentence-transformers",
|
|
32
32
|
"requests",
|
|
33
|
-
"openai"
|
|
33
|
+
"openai",
|
|
34
|
+
"PyGithub",
|
|
35
|
+
"schedule"
|
|
34
36
|
]
|
|
35
37
|
|
|
36
38
|
[project.urls]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from .core.decorator import vectorize
|
|
2
|
-
from .database.db import initialize_database
|
|
2
|
+
from .database.db import initialize_database, update_database_schema
|
|
3
3
|
from .database.db_search import search_functions, search_executions, search_errors_by_message, search_functions_hybrid
|
|
4
4
|
from .monitoring.tracer import trace_span
|
|
5
5
|
from .search.rag_search import search_and_answer, analyze_trace_log
|
|
@@ -25,5 +25,6 @@ __all__ = [
|
|
|
25
25
|
'VectorWaveReplayer',
|
|
26
26
|
'SemanticReplayer',
|
|
27
27
|
'VectorWaveDatasetManager',
|
|
28
|
-
'VectorWaveAutoInjector'
|
|
28
|
+
'VectorWaveAutoInjector',
|
|
29
|
+
'update_database_schema'
|
|
29
30
|
]
|
|
@@ -27,11 +27,18 @@ class WeaviateBatchManager:
|
|
|
27
27
|
Uses High-Performance Rust Core if available, otherwise falls back to Python.
|
|
28
28
|
"""
|
|
29
29
|
|
|
30
|
-
def __init__(self
|
|
30
|
+
def __init__(self, host: Optional[str] = None, port: Optional[int] = None,
|
|
31
|
+
grpc_port: Optional[int] = None, api_key: Optional[str] = None):
|
|
31
32
|
self._initialized = False
|
|
32
33
|
self.settings: WeaviateSettings = get_weaviate_settings()
|
|
33
34
|
self.client: Optional[weaviate.WeaviateClient] = None
|
|
34
35
|
|
|
36
|
+
# Store dynamic connection params
|
|
37
|
+
self._host = host
|
|
38
|
+
self._port = port
|
|
39
|
+
self._grpc_port = grpc_port
|
|
40
|
+
self._api_key = api_key
|
|
41
|
+
|
|
35
42
|
# Batch Configuration
|
|
36
43
|
self.batch_threshold = self.settings.BATCH_THRESHOLD
|
|
37
44
|
self.flush_interval = self.settings.FLUSH_INTERVAL_SECONDS
|
|
@@ -60,7 +67,13 @@ class WeaviateBatchManager:
|
|
|
60
67
|
def _connect_client(self):
|
|
61
68
|
"""Attempts to connect to Weaviate."""
|
|
62
69
|
try:
|
|
63
|
-
self.
|
|
70
|
+
if self._host is not None:
|
|
71
|
+
self.client = get_weaviate_client(
|
|
72
|
+
host=self._host, port=self._port,
|
|
73
|
+
grpc_port=self._grpc_port, api_key=self._api_key
|
|
74
|
+
)
|
|
75
|
+
else:
|
|
76
|
+
self.client = get_weaviate_client(self.settings)
|
|
64
77
|
if self.client:
|
|
65
78
|
self._initialized = True
|
|
66
79
|
except Exception as e:
|
|
@@ -171,6 +184,11 @@ class WeaviateBatchManager:
|
|
|
171
184
|
except:
|
|
172
185
|
pass
|
|
173
186
|
|
|
174
|
-
@lru_cache(
|
|
175
|
-
def get_batch_manager(
|
|
176
|
-
|
|
187
|
+
@lru_cache()
|
|
188
|
+
def get_batch_manager(
|
|
189
|
+
host: Optional[str] = None,
|
|
190
|
+
port: Optional[int] = None,
|
|
191
|
+
grpc_port: Optional[int] = None,
|
|
192
|
+
api_key: Optional[str] = None
|
|
193
|
+
) -> WeaviateBatchManager:
|
|
194
|
+
return WeaviateBatchManager(host=host, port=port, grpc_port=grpc_port, api_key=api_key)
|
|
@@ -23,7 +23,7 @@ def create_smart_wrapper(original_func, root_wrapper):
|
|
|
23
23
|
# Check for existing tracer at runtime
|
|
24
24
|
tracer = current_tracer_var.get()
|
|
25
25
|
|
|
26
|
-
if tracer:
|
|
26
|
+
if tracer is not None:
|
|
27
27
|
# [Case A] Parent trace exists -> Act as Child Span
|
|
28
28
|
# (Wrap original function with trace_span and execute)
|
|
29
29
|
return trace_span(original_func, capture_return_value=True)(*args, **kwargs)
|