ydb-qdrant 2.1.4 → 2.2.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/README.md +122 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,7 +83,11 @@ The package entrypoint exports a programmatic API that mirrors the Qdrant HTTP s
|
|
|
83
83
|
|
|
84
84
|
async function main() {
|
|
85
85
|
// defaultTenant is optional; defaults to "default"
|
|
86
|
-
const client = await createYdbQdrantClient({
|
|
86
|
+
const client = await createYdbQdrantClient({
|
|
87
|
+
defaultTenant: "myapp",
|
|
88
|
+
endpoint: "grpcs://lb.etn01g9tcilcon2mrt3h.ydb.mdb.yandexcloud.net:2135",
|
|
89
|
+
database: "/ru-central1/b1ge4v9r1l3h1q4njclp/etn01g9tcilcon2mrt3h",
|
|
90
|
+
});
|
|
87
91
|
|
|
88
92
|
await client.createCollection("documents", {
|
|
89
93
|
vectors: {
|
|
@@ -111,7 +115,10 @@ The package entrypoint exports a programmatic API that mirrors the Qdrant HTTP s
|
|
|
111
115
|
|
|
112
116
|
- Multi-tenant usage with `forTenant`:
|
|
113
117
|
```ts
|
|
114
|
-
const client = await createYdbQdrantClient(
|
|
118
|
+
const client = await createYdbQdrantClient({
|
|
119
|
+
endpoint: "grpcs://lb.etn01g9tcilcon2mrt3h.ydb.mdb.yandexcloud.net:2135",
|
|
120
|
+
database: "/ru-central1/b1ge4v9r1l3h1q4njclp/etn01g9tcilcon2mrt3h",
|
|
121
|
+
});
|
|
115
122
|
const tenantClient = client.forTenant("tenant-a");
|
|
116
123
|
|
|
117
124
|
await tenantClient.upsertPoints("sessions", {
|
|
@@ -121,6 +128,41 @@ The package entrypoint exports a programmatic API that mirrors the Qdrant HTTP s
|
|
|
121
128
|
|
|
122
129
|
The request/response shapes follow the same schemas as the HTTP API (`CreateCollectionReq`, `UpsertPointsReq`, `SearchReq`, `DeletePointsReq`), so code written against the REST API can usually be translated directly to the library calls.
|
|
123
130
|
|
|
131
|
+
### Example: in-process points search with a shared client
|
|
132
|
+
|
|
133
|
+
In a typical server application you create a single `ydb-qdrant` client once and reuse it across requests. Then you can perform vector search (points search) directly in your business logic:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import {createYdbQdrantClient} from 'ydb-qdrant';
|
|
137
|
+
|
|
138
|
+
let clientPromise: ReturnType<typeof createYdbQdrantClient> | null = null;
|
|
139
|
+
|
|
140
|
+
async function getClient() {
|
|
141
|
+
if (!clientPromise) {
|
|
142
|
+
clientPromise = createYdbQdrantClient({
|
|
143
|
+
defaultTenant: 'myapp',
|
|
144
|
+
endpoint: 'grpcs://lb.etn01g9tcilcon2mrt3h.ydb.mdb.yandexcloud.net:2135',
|
|
145
|
+
database: '/ru-central1/b1ge4v9r1l3h1q4njclp/etn01g9tcilcon2mrt3h',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return clientPromise;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export async function searchDocuments(collection: string, queryEmbedding: number[], top: number) {
|
|
152
|
+
const client = await getClient();
|
|
153
|
+
|
|
154
|
+
const result = await client.searchPoints(collection, {
|
|
155
|
+
vector: queryEmbedding,
|
|
156
|
+
top,
|
|
157
|
+
with_payload: true,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return result.points ?? [];
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This pattern avoids running a separate HTTP service: vector search is executed directly against YDB via the shared `createYdbQdrantClient` instance, while the rest of your code works with plain TypeScript functions.
|
|
165
|
+
|
|
124
166
|
## Quick Start
|
|
125
167
|
|
|
126
168
|
### Use with IDE agents (Roo Code, Cline)
|
|
@@ -182,6 +224,84 @@ Health check:
|
|
|
182
224
|
curl -s http://localhost:8080/health
|
|
183
225
|
```
|
|
184
226
|
|
|
227
|
+
### Docker (self-hosted HTTP server)
|
|
228
|
+
|
|
229
|
+
Published container: [`ghcr.io/astandrik/ydb-qdrant`](https://github.com/users/astandrik/packages/container/package/ydb-qdrant)
|
|
230
|
+
|
|
231
|
+
**Option A – pull the published image (recommended)**
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
docker pull ghcr.io/astandrik/ydb-qdrant:latest
|
|
235
|
+
|
|
236
|
+
docker run -d --name ydb-qdrant \
|
|
237
|
+
-p 8080:8080 \
|
|
238
|
+
-e YDB_ENDPOINT=grpcs://ydb.serverless.yandexcloud.net:2135 \
|
|
239
|
+
-e YDB_DATABASE=/ru-central1/<cloud>/<db> \
|
|
240
|
+
-e YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS=/sa-key.json \
|
|
241
|
+
-v /abs/path/sa-key.json:/sa-key.json:ro \
|
|
242
|
+
ghcr.io/astandrik/ydb-qdrant:latest
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Option B – build the image locally**
|
|
246
|
+
|
|
247
|
+
From the `ydb-qdrant/` directory:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
docker build -t ydb-qdrant:latest .
|
|
251
|
+
|
|
252
|
+
docker run -d --name ydb-qdrant \
|
|
253
|
+
-p 8080:8080 \
|
|
254
|
+
-e YDB_ENDPOINT=grpcs://ydb.serverless.yandexcloud.net:2135 \
|
|
255
|
+
-e YDB_DATABASE=/ru-central1/<cloud>/<db> \
|
|
256
|
+
-e YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS=/sa-key.json \
|
|
257
|
+
-v /abs/path/sa-key.json:/sa-key.json:ro \
|
|
258
|
+
ydb-qdrant:latest
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### Docker Compose
|
|
262
|
+
|
|
263
|
+
Example `docker-compose.yml` (can be used instead of raw `docker run`):
|
|
264
|
+
|
|
265
|
+
```yaml
|
|
266
|
+
services:
|
|
267
|
+
ydb-qdrant:
|
|
268
|
+
image: ghcr.io/astandrik/ydb-qdrant:latest
|
|
269
|
+
ports:
|
|
270
|
+
- "8080:8080"
|
|
271
|
+
env_file:
|
|
272
|
+
- .env
|
|
273
|
+
environment:
|
|
274
|
+
YDB_ENDPOINT: ${YDB_ENDPOINT}
|
|
275
|
+
YDB_DATABASE: ${YDB_DATABASE}
|
|
276
|
+
YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS: /sa-key.json
|
|
277
|
+
PORT: ${PORT:-8080}
|
|
278
|
+
LOG_LEVEL: ${LOG_LEVEL:-info}
|
|
279
|
+
volumes:
|
|
280
|
+
- ${YDB_SA_KEY_PATH}:/sa-key.json:ro
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Example `.env` (per environment):
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
YDB_ENDPOINT=grpcs://ydb.serverless.yandexcloud.net:2135
|
|
287
|
+
YDB_DATABASE=/ru-central1/<cloud>/<db>
|
|
288
|
+
YDB_SA_KEY_PATH=/abs/path/to/ydb-sa.json
|
|
289
|
+
PORT=8080
|
|
290
|
+
LOG_LEVEL=info
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
- **Updating to a newer image with Compose** (no rebuild):
|
|
294
|
+
- Pull the latest tag and restart the service:
|
|
295
|
+
```bash
|
|
296
|
+
docker compose pull ydb-qdrant # or: docker-compose pull ydb-qdrant
|
|
297
|
+
docker compose up -d ydb-qdrant # or: docker-compose up -d ydb-qdrant
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
- **Environment**: uses the same variables as documented in **Configure credentials** (`YDB_ENDPOINT`, `YDB_DATABASE`, one of the `YDB_*_CREDENTIALS` options, optional `PORT`/`LOG_LEVEL`).
|
|
301
|
+
- **Qdrant URL for tools/clients**: set to `http://localhost:8080` (or `http://<host>:<hostPort>` if you map a different port).
|
|
302
|
+
- **Health check inside container**: `GET http://localhost:8080/health`.
|
|
303
|
+
|
|
304
|
+
|
|
185
305
|
## API Reference
|
|
186
306
|
|
|
187
307
|
Create collection (PUT /collections/{collection}):
|