redis-vl 0.1.0-beta.0
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.
- package/LICENSE +22 -0
- package/README.md +212 -0
- package/dist/errors.d.ts +50 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +87 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes/search-index.d.ts +368 -0
- package/dist/indexes/search-index.d.ts.map +1 -0
- package/dist/indexes/search-index.js +475 -0
- package/dist/indexes/search-index.js.map +1 -0
- package/dist/query/base.d.ts +51 -0
- package/dist/query/base.d.ts.map +1 -0
- package/dist/query/base.js +6 -0
- package/dist/query/base.js.map +1 -0
- package/dist/query/index.d.ts +7 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +7 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/vector.d.ts +199 -0
- package/dist/query/vector.d.ts.map +1 -0
- package/dist/query/vector.js +198 -0
- package/dist/query/vector.js.map +1 -0
- package/dist/redis/index-info-parser.d.ts +25 -0
- package/dist/redis/index-info-parser.d.ts.map +1 -0
- package/dist/redis/index-info-parser.js +301 -0
- package/dist/redis/index-info-parser.js.map +1 -0
- package/dist/redis/schema-types.d.ts +81 -0
- package/dist/redis/schema-types.d.ts.map +1 -0
- package/dist/redis/schema-types.js +18 -0
- package/dist/redis/schema-types.js.map +1 -0
- package/dist/redis/utils.d.ts +7 -0
- package/dist/redis/utils.d.ts.map +1 -0
- package/dist/redis/utils.js +221 -0
- package/dist/redis/utils.js.map +1 -0
- package/dist/schema/fields.d.ts +163 -0
- package/dist/schema/fields.d.ts.map +1 -0
- package/dist/schema/fields.js +304 -0
- package/dist/schema/fields.js.map +1 -0
- package/dist/schema/index.d.ts +8 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +8 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/schema.d.ts +247 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +403 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/types.d.ts +56 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +62 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/storage/base-storage.d.ts +107 -0
- package/dist/storage/base-storage.d.ts.map +1 -0
- package/dist/storage/base-storage.js +187 -0
- package/dist/storage/base-storage.js.map +1 -0
- package/dist/storage/hash-storage.d.ts +29 -0
- package/dist/storage/hash-storage.d.ts.map +1 -0
- package/dist/storage/hash-storage.js +122 -0
- package/dist/storage/hash-storage.js.map +1 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +4 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/json-storage.d.ts +19 -0
- package/dist/storage/json-storage.d.ts.map +1 -0
- package/dist/storage/json-storage.js +81 -0
- package/dist/storage/json-storage.js.map +1 -0
- package/dist/utils/distance.d.ts +92 -0
- package/dist/utils/distance.d.ts.map +1 -0
- package/dist/utils/distance.js +98 -0
- package/dist/utils/distance.js.map +1 -0
- package/dist/vectorizers/base-vectorizer.d.ts +88 -0
- package/dist/vectorizers/base-vectorizer.d.ts.map +1 -0
- package/dist/vectorizers/base-vectorizer.js +32 -0
- package/dist/vectorizers/base-vectorizer.js.map +1 -0
- package/dist/vectorizers/huggingface-vectorizer.d.ts +103 -0
- package/dist/vectorizers/huggingface-vectorizer.d.ts.map +1 -0
- package/dist/vectorizers/huggingface-vectorizer.js +142 -0
- package/dist/vectorizers/huggingface-vectorizer.js.map +1 -0
- package/dist/vectorizers/index.d.ts +10 -0
- package/dist/vectorizers/index.d.ts.map +1 -0
- package/dist/vectorizers/index.js +10 -0
- package/dist/vectorizers/index.js.map +1 -0
- package/package.json +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Redis, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img width="300" src="https://redis.io/wp-content/uploads/2024/04/Logotype.svg" alt="Redis">
|
|
3
|
+
<h1>Redis Vector Library</h1>
|
|
4
|
+
<p><strong>The AI-native Redis TypeScript/Node.js client</strong></p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
> **⚠️** RedisVL TypeScript is in active development. APIs may change before v1.0 release.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Introduction
|
|
23
|
+
|
|
24
|
+
Redis Vector Library (RedisVL) is the TypeScript/Node.js client for building AI applications on Redis.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **Index Management** — Schema design, data loading, and CRUD operations
|
|
29
|
+
- **Vector Search** — Similarity search with metadata filters and hybrid queries via `VectorQuery`
|
|
30
|
+
- **Vectorizers** — HuggingFace embeddings for semantic search
|
|
31
|
+
- **Distance Normalization** — User-friendly 0–1 similarity scores
|
|
32
|
+
|
|
33
|
+
### Use Cases
|
|
34
|
+
|
|
35
|
+
- **RAG Pipelines** — Combine vector similarity search with metadata filtering to retrieve the most relevant context for your LLMs
|
|
36
|
+
- **Recommendation Systems** — Find similar items using vector similarity search
|
|
37
|
+
|
|
38
|
+
## Getting Started
|
|
39
|
+
|
|
40
|
+
> [!WARNING]
|
|
41
|
+
> `RedisVL TypeScript` is in beta. APIs, defaults, and the package itself may change between minor versions.
|
|
42
|
+
|
|
43
|
+
**Option A: Install from npm:**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install redis-vl@beta
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Option B: Install from source** by cloning the repo and linking it locally:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/redis-developer/redis-vl-typescript.git
|
|
53
|
+
cd redis-vl-typescript
|
|
54
|
+
npm install
|
|
55
|
+
npm run build
|
|
56
|
+
npm link
|
|
57
|
+
# then in your project:
|
|
58
|
+
npm link redis-vl
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Redis
|
|
62
|
+
|
|
63
|
+
Choose from multiple Redis deployment options:
|
|
64
|
+
|
|
65
|
+
1. [Redis Cloud](https://redis.io/try-free): Managed cloud database (free tier available)
|
|
66
|
+
2. [Redis Stack](https://redis.io/docs/getting-started/install-stack/docker/): Docker image for development
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> Enhance your experience and observability with the free [Redis Insight GUI](https://redis.io/insight/).
|
|
73
|
+
|
|
74
|
+
## Overview
|
|
75
|
+
|
|
76
|
+
RedisVL is a TypeScript client for building AI applications on Redis. It sits on top of [node-redis](https://github.com/redis/node-redis) and handles the common patterns you need: managing indexes, loading data, generating embeddings, vector search, and techniques like semantic caching and LLM memory to improve the performance of your AI applications at scale.
|
|
77
|
+
|
|
78
|
+
**What it does:**
|
|
79
|
+
|
|
80
|
+
- **Schema Management** - Define indexes with YAML or objects
|
|
81
|
+
- **Vector Search** - Semantic similarity search with metadata filtering
|
|
82
|
+
- **Data Operations** - Batch loading with validation, TTL, and preprocessing
|
|
83
|
+
- **Embeddings** - Generate vectors with HuggingFace (local, no API key)
|
|
84
|
+
- **Type Safety** - Full TypeScript support
|
|
85
|
+
|
|
86
|
+
📚 **[Read the full documentation →](https://redis-developer.github.io/redis-vl-typescript/)**
|
|
87
|
+
|
|
88
|
+
## Features
|
|
89
|
+
|
|
90
|
+
### Schema Definition
|
|
91
|
+
|
|
92
|
+
Define your data structure with fields for text, tags, numbers, geo locations, and vectors:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { IndexSchema } from 'redis-vl';
|
|
96
|
+
|
|
97
|
+
const schema = IndexSchema.fromObject({
|
|
98
|
+
index: { name: 'products', prefix: 'product:', storage_type: 'json' },
|
|
99
|
+
fields: [
|
|
100
|
+
{ name: 'title', type: 'text' },
|
|
101
|
+
{ name: 'category', type: 'tag' },
|
|
102
|
+
{ name: 'price', type: 'numeric' },
|
|
103
|
+
{
|
|
104
|
+
name: 'embedding',
|
|
105
|
+
type: 'vector',
|
|
106
|
+
attrs: { algorithm: 'hnsw', dims: 768, distance_metric: 'cosine' },
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**[Learn more about schemas →](https://redis-developer.github.io/redis-vl-typescript/docs/user-guide/schema)**
|
|
113
|
+
|
|
114
|
+
### Index Operations
|
|
115
|
+
|
|
116
|
+
Create and manage search indexes:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { createClient } from 'redis';
|
|
120
|
+
import { SearchIndex } from 'redis-vl';
|
|
121
|
+
|
|
122
|
+
const client = createClient();
|
|
123
|
+
await client.connect();
|
|
124
|
+
|
|
125
|
+
const index = new SearchIndex(schema, client);
|
|
126
|
+
await index.create();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**[Learn more about indexes →](https://redis-developer.github.io/redis-vl-typescript/docs/user-guide/search-index)**
|
|
130
|
+
|
|
131
|
+
### Data Loading & Retrieval
|
|
132
|
+
|
|
133
|
+
Load documents and retrieve them by key:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const documents = [
|
|
137
|
+
{ id: '1', title: 'Product A', price: 99 },
|
|
138
|
+
{ id: '2', title: 'Product B', price: 149 },
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
// Load with explicit IDs
|
|
142
|
+
await index.load(documents, { idField: 'id' });
|
|
143
|
+
|
|
144
|
+
// Fetch documents
|
|
145
|
+
const doc = await index.fetch('1');
|
|
146
|
+
const docs = await index.fetchMany(['1', '2']);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**[Learn more about CRUD operations →](https://redis-developer.github.io/redis-vl-typescript/docs/user-guide/search-index#crud-operations)**
|
|
150
|
+
|
|
151
|
+
### Vector Search
|
|
152
|
+
|
|
153
|
+
Perform semantic similarity search:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { VectorQuery } from 'redis-vl';
|
|
157
|
+
|
|
158
|
+
// Create query
|
|
159
|
+
const query = new VectorQuery({
|
|
160
|
+
vector: embedding,
|
|
161
|
+
vectorField: 'embedding',
|
|
162
|
+
filter: '@category:{electronics}',
|
|
163
|
+
numResults: 10,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Execute search
|
|
167
|
+
const results = await index.search(query);
|
|
168
|
+
results.documents.forEach((doc) => {
|
|
169
|
+
console.log(`${doc.value.title} (score: ${doc.score})`);
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**[Learn more about vector search →](https://redis-developer.github.io/redis-vl-typescript/docs/user-guide/search-index#vector-search)**
|
|
174
|
+
|
|
175
|
+
### Vectorizers
|
|
176
|
+
|
|
177
|
+
Generate embeddings for semantic search:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import { HuggingFaceVectorizer } from 'redis-vl';
|
|
181
|
+
|
|
182
|
+
const vectorizer = new HuggingFaceVectorizer({
|
|
183
|
+
model: 'Xenova/all-MiniLM-L6-v2',
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const embedding = await vectorizer.embed('Hello world');
|
|
187
|
+
|
|
188
|
+
// Use with data loading
|
|
189
|
+
await index.load(documents, {
|
|
190
|
+
preprocess: async (doc) => ({
|
|
191
|
+
...doc,
|
|
192
|
+
embedding: await vectorizer.embed(doc.content),
|
|
193
|
+
}),
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**[Learn more about vectorizers →](https://redis-developer.github.io/redis-vl-typescript/docs/user-guide/vectorizers)**
|
|
198
|
+
|
|
199
|
+
## Coming Soon
|
|
200
|
+
|
|
201
|
+
- **Hybrid Search** - Combine vector, text, and numeric filters
|
|
202
|
+
- **Range Queries** - Vector search within distance range
|
|
203
|
+
- **Semantic Caching** - Cache LLM responses by similarity
|
|
204
|
+
- **LLM Memory** - Context management for AI agents
|
|
205
|
+
- **Semantic Routing** - Intent-based query classification
|
|
206
|
+
- **More Vectorizers** - OpenAI, Cohere, Azure, VertexAI
|
|
207
|
+
|
|
208
|
+
## Helpful Links
|
|
209
|
+
|
|
210
|
+
For additional help, check out the following resources:
|
|
211
|
+
|
|
212
|
+
- [Redis AI Recipes](https://github.com/redis-developer/redis-ai-resources)
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Errors
|
|
3
|
+
* Custom exception classes for RedisVL error handling.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base exception for all RedisVL errors.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RedisVLError extends Error {
|
|
9
|
+
constructor(message: string, options?: ErrorOptions);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Error raised for Redis Search specific operations.
|
|
13
|
+
*/
|
|
14
|
+
export declare class RedisSearchError extends RedisVLError {
|
|
15
|
+
constructor(message: string, options?: ErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Error when validating data against a schema.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SchemaValidationError extends RedisVLError {
|
|
21
|
+
readonly index?: number;
|
|
22
|
+
constructor(message: string, indexOrOptions?: number | ErrorOptions);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Error when validating a query.
|
|
26
|
+
*/
|
|
27
|
+
export declare class QueryValidationError extends RedisVLError {
|
|
28
|
+
constructor(message: string, options?: ErrorOptions);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Error when Redis or module versions are incompatible.
|
|
32
|
+
*/
|
|
33
|
+
export declare class RedisModuleVersionError extends RedisVLError {
|
|
34
|
+
constructor(message: string, options?: ErrorOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Create error for unsupported features requiring specific Redis versions.
|
|
37
|
+
*
|
|
38
|
+
* @param feature - Name of the feature requiring a specific version
|
|
39
|
+
* @param minVersion - Minimum required Redis version
|
|
40
|
+
* @param suggestion - Suggested action to resolve the issue
|
|
41
|
+
*/
|
|
42
|
+
static forFeature(feature: string, minVersion: string, suggestion: string): RedisModuleVersionError;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error raised for vectorizer operations.
|
|
46
|
+
*/
|
|
47
|
+
export declare class VectorizerError extends RedisVLError {
|
|
48
|
+
constructor(message: string, options?: ErrorOptions);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAQtD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAItD;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,YAAY;IACnD,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEnB,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,YAAY;CAmBtE;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;gBACtC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAItD;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,YAAY;gBACzC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;IAKnD;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CACb,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACnB,uBAAuB;CAK7B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAItD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Errors
|
|
3
|
+
* Custom exception classes for RedisVL error handling.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base exception for all RedisVL errors.
|
|
7
|
+
*/
|
|
8
|
+
export class RedisVLError extends Error {
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = 'RedisVLError';
|
|
12
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
13
|
+
if (Error.captureStackTrace) {
|
|
14
|
+
Error.captureStackTrace(this, this.constructor);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error raised for Redis Search specific operations.
|
|
20
|
+
*/
|
|
21
|
+
export class RedisSearchError extends RedisVLError {
|
|
22
|
+
constructor(message, options) {
|
|
23
|
+
super(message, options);
|
|
24
|
+
this.name = 'RedisSearchError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Error when validating data against a schema.
|
|
29
|
+
*/
|
|
30
|
+
export class SchemaValidationError extends RedisVLError {
|
|
31
|
+
index;
|
|
32
|
+
constructor(message, indexOrOptions) {
|
|
33
|
+
let index;
|
|
34
|
+
let options;
|
|
35
|
+
if (typeof indexOrOptions === 'number') {
|
|
36
|
+
index = indexOrOptions;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
options = indexOrOptions;
|
|
40
|
+
}
|
|
41
|
+
// Only add index prefix if the message doesn't already contain detailed validation info
|
|
42
|
+
if (index !== undefined && !message.startsWith('Schema validation failed')) {
|
|
43
|
+
message = `Validation failed for object at index ${index}: ${message}`;
|
|
44
|
+
}
|
|
45
|
+
super(message, options);
|
|
46
|
+
this.name = 'SchemaValidationError';
|
|
47
|
+
this.index = index;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Error when validating a query.
|
|
52
|
+
*/
|
|
53
|
+
export class QueryValidationError extends RedisVLError {
|
|
54
|
+
constructor(message, options) {
|
|
55
|
+
super(message, options);
|
|
56
|
+
this.name = 'QueryValidationError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Error when Redis or module versions are incompatible.
|
|
61
|
+
*/
|
|
62
|
+
export class RedisModuleVersionError extends RedisVLError {
|
|
63
|
+
constructor(message, options) {
|
|
64
|
+
super(message, options);
|
|
65
|
+
this.name = 'RedisModuleVersionError';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create error for unsupported features requiring specific Redis versions.
|
|
69
|
+
*
|
|
70
|
+
* @param feature - Name of the feature requiring a specific version
|
|
71
|
+
* @param minVersion - Minimum required Redis version
|
|
72
|
+
* @param suggestion - Suggested action to resolve the issue
|
|
73
|
+
*/
|
|
74
|
+
static forFeature(feature, minVersion, suggestion) {
|
|
75
|
+
return new RedisModuleVersionError(`${feature} requires Redis >= ${minVersion}. ${suggestion}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Error raised for vectorizer operations.
|
|
80
|
+
*/
|
|
81
|
+
export class VectorizerError extends RedisVLError {
|
|
82
|
+
constructor(message, options) {
|
|
83
|
+
super(message, options);
|
|
84
|
+
this.name = 'VectorizerError';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACnC,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,qFAAqF;QACrF,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9C,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACnC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnC,KAAK,CAAU;IAE/B,YAAY,OAAe,EAAE,cAAsC;QAC/D,IAAI,KAAyB,CAAC;QAC9B,IAAI,OAAiC,CAAC;QAEtC,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;YACrC,KAAK,GAAG,cAAc,CAAC;QAC3B,CAAC;aAAM,CAAC;YACJ,OAAO,GAAG,cAAc,CAAC;QAC7B,CAAC;QAED,wFAAwF;QACxF,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC;YACzE,OAAO,GAAG,yCAAyC,KAAK,KAAK,OAAO,EAAE,CAAC;QAC3E,CAAC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IAClD,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACvC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IACrD,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CACb,OAAe,EACf,UAAkB,EAClB,UAAkB;QAElB,OAAO,IAAI,uBAAuB,CAC9B,GAAG,OAAO,sBAAsB,UAAU,KAAK,UAAU,EAAE,CAC9D,CAAC;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAC7C,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis Vector Library for TypeScript/Node.js
|
|
3
|
+
*
|
|
4
|
+
* The AI-native Redis client for vector operations
|
|
5
|
+
*/
|
|
6
|
+
export declare const version = "0.1.0";
|
|
7
|
+
export { IndexSchema, IndexInfo } from './schema/schema.js';
|
|
8
|
+
export { BaseField, TextField, TagField, NumericField, GeoField, VectorField, // Generic VectorField (supports FLAT and HNSW)
|
|
9
|
+
FlatVectorField, // Algorithm-specific (FLAT only)
|
|
10
|
+
HNSWVectorField, // Algorithm-specific (HNSW only)
|
|
11
|
+
FieldFactory, } from './schema/fields.js';
|
|
12
|
+
export * from './schema/types.js';
|
|
13
|
+
export { SearchIndex } from './indexes/search-index.js';
|
|
14
|
+
export type { CreateIndexOptions, DeleteIndexOptions } from './indexes/search-index.js';
|
|
15
|
+
export { VectorQuery } from './query/vector.js';
|
|
16
|
+
export type { VectorQueryConfig, HybridPolicy, UseSearchHistory } from './query/vector.js';
|
|
17
|
+
export type { BaseQuery, SearchResult, SearchDocument, QueryOptions } from './query/base.js';
|
|
18
|
+
export { RedisVLError, RedisSearchError, SchemaValidationError, QueryValidationError, RedisModuleVersionError, VectorizerError, } from './errors.js';
|
|
19
|
+
export { BaseVectorizer, HuggingFaceVectorizer, type HuggingFaceConfig, } from './vectorizers/index.js';
|
|
20
|
+
export { normalizeCosineDistance, denormalizeCosineDistance, normalizeL2Distance, DISTANCE_NORMALIZERS, type DistanceNormalizer, } from './utils/distance.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACH,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,WAAW,EAAE,+CAA+C;AAC5D,eAAe,EAAE,iCAAiC;AAClD,eAAe,EAAE,iCAAiC;AAClD,YAAY,GACf,MAAM,oBAAoB,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGxF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG7F,OAAO,EACH,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACH,cAAc,EACd,qBAAqB,EACrB,KAAK,iBAAiB,GACzB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACH,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,kBAAkB,GAC1B,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis Vector Library for TypeScript/Node.js
|
|
3
|
+
*
|
|
4
|
+
* The AI-native Redis client for vector operations
|
|
5
|
+
*/
|
|
6
|
+
// Version
|
|
7
|
+
export const version = '0.1.0';
|
|
8
|
+
// Schema exports
|
|
9
|
+
export { IndexSchema, IndexInfo } from './schema/schema.js';
|
|
10
|
+
export { BaseField, TextField, TagField, NumericField, GeoField, VectorField, // Generic VectorField (supports FLAT and HNSW)
|
|
11
|
+
FlatVectorField, // Algorithm-specific (FLAT only)
|
|
12
|
+
HNSWVectorField, // Algorithm-specific (HNSW only)
|
|
13
|
+
FieldFactory, } from './schema/fields.js';
|
|
14
|
+
export * from './schema/types.js';
|
|
15
|
+
// Index exports
|
|
16
|
+
export { SearchIndex } from './indexes/search-index.js';
|
|
17
|
+
// Query exports
|
|
18
|
+
export { VectorQuery } from './query/vector.js';
|
|
19
|
+
// Error exports
|
|
20
|
+
export { RedisVLError, RedisSearchError, SchemaValidationError, QueryValidationError, RedisModuleVersionError, VectorizerError, } from './errors.js';
|
|
21
|
+
// Vectorizer exports
|
|
22
|
+
export { BaseVectorizer, HuggingFaceVectorizer, } from './vectorizers/index.js';
|
|
23
|
+
// Utility exports
|
|
24
|
+
export { normalizeCosineDistance, denormalizeCosineDistance, normalizeL2Distance, DISTANCE_NORMALIZERS, } from './utils/distance.js';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,UAAU;AACV,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,iBAAiB;AACjB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACH,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,WAAW,EAAE,+CAA+C;AAC5D,eAAe,EAAE,iCAAiC;AAClD,eAAe,EAAE,iCAAiC;AAClD,YAAY,GACf,MAAM,oBAAoB,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAElC,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,gBAAgB;AAChB,OAAO,EACH,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,GAClB,MAAM,aAAa,CAAC;AAErB,qBAAqB;AACrB,OAAO,EACH,cAAc,EACd,qBAAqB,GAExB,MAAM,wBAAwB,CAAC;AAEhC,kBAAkB;AAClB,OAAO,EACH,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,GAEvB,MAAM,qBAAqB,CAAC"}
|